|
I need help adding html helpers,partial pages,JavaScript ,DbInitializer
|
|
|
|
|
As Dave already suggested, you need to Google for articles or get hold of a good book. No one here is going to do the work for you.
|
|
|
|
|
|
I currently have a solution which contains two projects: an ASP.NET site and a Web API project. On the site, I have a page that is meant to call the API using the POST method at address http://localhost:52855/api/v1/GetPrices asynchronously (e.g. response = await base.SendAsync(request, cancellationToken where "base" is a DelegatingHandler). Part of the data that is posted is an API key along with a signature to ensure the user is authorized. However, nothing happens; the Chrome tab just shows the loading symbol continuously.
But, if I use Fiddler and make a POST request to the same address (http://localhost:52855/api/v1/GetPrices), but without the API/signature information, I get back the correct response - a 401 Unauthorized and a "WWW-Authenticate: amx" header (where "amx" is the authentication scheme I'm using for testing. If I include the authorization header in Fiddler then I get a 500 Internal Server Error
My biggest question is how can I debug the Web API project in Visual Studio 2017 Enterprise edition? I have breakpoints set on all the methods (e.g. the Post method in my GetPricesController : ApiController as well as my HMACAuthenticationAttribute which implements the IAuthenticationFilter). I feel that if I can at least start seeing what's going on when I make the requests with Fiddler, that I may be able to figure out the web app from there.
I'm supposed to be doing a demo on this Web API project tomorrow early afternoon and I've been working for the back 11 hours on finishing this up but I'm completely stalled now and have no idea where to go from here. Any help/guidance would be so greatly appreciated. Thank you.
P.S. I was using this article http://bitoftech.net/2014/12/15/secure-asp-net-web-api-using-api-key-authentication-hmac-authentication/ to implement the API key validation.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Hi,
To debug your API you can write another console application which calls your API. Set the api url to your localhost address, then run your WEB API project(by setting the start project on it), now when you run your console application and call your API, your break point will work 
|
|
|
|
|
guys Can you help me with this issue i do not know how to write EditItemTempalte in gridView wih sqlCommand !!!!!can you give me sample code 
modified 26-Nov-18 3:31am.
|
|
|
|
|
Are list contents volatile ? e.g I've declared a list
Dim AdminFinalFilename As New List(Of String)
On a button press I pass a string into the list
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
finalfilename = DateTime.Now.ToString("ddMMyyhhmm") + "_" + FileUpload1.FileName
AdminFormFilename.Add(finalfilename)
End Sub
On pressing another button the contents of the list disappear
Protected Sub FormSubmit_Click(sender As Object, e As EventArgs) Handles FormSubmit.Click
If AdminFinalFilename Is Nothing Then
Else
Dim i As Integer
For i = 0 To AdminFinalFilename.Count - 1
Dim y As New accessadminreq
y.InsertAdminUpload(FormID, (AdminFinalFilename.Item(i)))
Next i
End If
End Sub
|
|
|
|
|
You are adding items to AdminFormFilename , but listing from AdminFinalFilename ?
|
|
|
|
|
My bad, I posted the wrong paste sorry
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
finalfilename = DateTime.Now.ToString("ddMMyyhhmm") + "_" + FileUpload1.FileName
AdminFinalFilename.Add(finalfilename)
End Sub
|
|
|
|
|
Values stored in fields are not persisted between requests. This is a common misunderstanding of how ASP.NET works.
The browser makes a request. ASP.NET creates a new instance of your page class, and loads any data that was included in the request via the query-string or a form POST. The page then processes the request, and generates a response. The response is sent to the browser, and the instance of your page class is thrown away.
When the browser makes its next request, it's processed by a new instance of your page class, which doesn't carry over any of the field values from the previous instance.
To make data persist between requests, it either needs to be stored in the session, or included in the query-string or form POST data for the next request. The standard approach for data that only relates to a single page is to use view state.
Understanding ASP.NET View State[^]
NB: Judging by the variable names, you've also hit another common misunderstanding about how file uploads work. The FileName property is the path - or sometimes just the name - of the file on the user's computer. It is included for information only. Your code is running on the server, and has no access to that path.
Instead, you need to save the file somewhere on the server, or read the file data from the input stream and process it.
How to: Upload Files with the FileUpload Web Server Control[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks, the file upload works this was some example code - I usually get the path with
Dim path As String = Server.MapPath("~/Uploads/")
and upload with
FileUpload1.PostedFile.SaveAs(path & _
finalfilename)
Saves the files fine, I'm just trying to loop through if there is more than one uploaded file and insert them into a database for retrieval later.
What's odd is I just threw together a test with this and it works like I thought it should
Dim mylist As New List(Of String)
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
mylist.Add("button3 clicked")
Dim i As Integer
For i = 0 To mylist.Count - 1
Label4.Text = Label4.Text + (mylist.Item(i)) + "<br>"
Next i
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
mylist.Add("button4 clicked")
Dim i As Integer
For i = 0 To mylist.Count - 1
Label4.Text = Label4.Text + (mylist.Item(i)) + "<br>"
Next i
End Sub
|
|
|
|
|
caffrey_1 wrote: it works like I thought it should
I doubt that.
The label's text will be persisted between requests, because it uses view state. When you append the items from the list, you're only appending a single item each time; the previous items were already in there.
If you debug your code and look at the myList field, you'll see it's empty when you click the button.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Your right, I'm having a day
Thanks for the pointer - I think I can get it fixed now
Problem I have I mix between coding in vb and aspx most days!
Thanks
|
|
|
|
|
Hi,
I have two reports in my Application, Report A is without Groups in it, and Report B with Groups in it, both are set with Columns Property: Column Headers -> Repeat Header Columns on each Page,
but the Report without Groups is showing column headers on each Page, when Report B with groups is not showing the Column headers on each page. Any help please, I am using ReportViewerForMVC tool for the Report viewing, maybe if it has any impact on it.
Just in case I selected the Row Headers - Report header column on each page too still didn't help.
But any help would be greatly helpful - thanks in advance friends
|
|
|
|
|
|
Beginner asking a question before he makes a recommendation to his boss!!!
I have been tasked with fixing a database issue for my company and I need to ensure I am on the right track so I am asking here for confirmation.
Our current process is we use two forms for input into our database.
A registration form on Wordpress and a Facebook leads form
We take the information from there and we input it into Zoho and a Mysql database behind a Wordpress web portal.
The file format we use is CSV. My understanding of CSV is that the data fields have to match the database table. If there is a column mismatch between the file and the database, data will go into the wrong field unless it is processed in some form to move the column in the CSV file. That is my understanding. Am I correct in this?
So, if my above assumption is correct, then it would be logical that the forms used would need to be standardised in order to ensure the data format is standardised. Please let me now if I am on the right track with this. Thanks
|
|
|
|
|
Yes you are on the correct track with this info. If you are importing directly from the CSV then the file format MUST match the database fields. You could write a parser which does the importing for you, this would give you an opportunity to trap crappy data before it hits your DB.
CSV has some gotchas, if it is not well formed, dealing with commas in the data, then you are in big trouble.
"Form" implies a standardised format otherwise it is just free form text.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I have to write ASP .NET code that allows for a user to only have one application session active at a time. What the code needs to do is logout an existing user, or session, if the same user logs into the same application in a different browser. In other words the new session should kill the old or existing session. Has anyone done this before? One note is that I am using Windows authentication and not Forms.
modified 18-Nov-18 15:07pm.
|
|
|
|
|
holdorf wrote: One note is that I am using Windows authentication and not Forms.
It's almost impossible to sign out if you're using Windows authentication. In most cases, the only way to accomplish it is to restart the browser.
One possible option:
- In a database, map the username to a Guid representing their "active session";
- In the "authorize request" event, check for the existence of a custom cookie:
- If the cookie exists, verify that its value matches the user's "active session" value in the database, and allow or deny the request as required;
- If the cookie doesn't exist, change the user's "active session" value in the database, and set a session cookie on the response with the new value;
Once a user has been kicked off by signing in on another browser or device, they will need to restart their browser to sign in again.
NB: Certain browser settings may cause the browser to retain session cookies even after a restart, which would mean the user would have to manually clear the cookies for your site to sign in again. This affects both Chrome[^] and Firefox[^], and possibly others.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
i am trying to make a REST server with and a client with an oData service.
The server is running and with the restlet tool i can send request and receive the correct information.
the debug from the restlet tool looks:
{
"name": "Microsoft.ApplicationInsights.Dev.Request",
"time": "2018-11-17T19:36:06.4656803Z",
"tags": {
"ai.internal.sdkVersion": "web: 2.0.0.25000",
"ai.device.roleInstance": "Kodi-PC",
"ai.location.ip": "192.168.2.146",
"ai.operation.name": "GET Employees [id]",
"ai.operation.id": "3sUDPXBnJTQ="
},
"data": {
"baseType": "RequestData",
"baseData": {
"ver": 2,
"id": "3sUDPXBnJTQ=",
"name": "GET Employees [id]",
"startTime": "2018-11-17T19:36:06.4656803+00:00",
"duration": "00:00:00.6869570",
"success": true,
"responseCode": "200",
"url": "http://192.168.2.21:3000/api/Employees/2",
"httpMethod": "GET",
"properties": {
"DeveloperMode": "true"
}
}
}
}
but the debug from the oData client looks:
{
"name": "Microsoft.ApplicationInsights.Dev.Request",
"time": "2018-11-17T19:39:47.1503444Z",
"tags": {
"ai.internal.sdkVersion": "web: 2.0.0.25000",
"ai.device.roleInstance": "Kodi-PC",
"ai.location.ip": "192.168.2.21",
"ai.operation.name": "GET employees(2L)",
"ai.operation.id": "gt/hDaz3z0A="
},
"data": {
"baseType": "RequestData",
"baseData": {
"ver": 2,
"id": "gt/hDaz3z0A=",
"name": "GET employees(2L)",
"startTime": "2018-11-17T19:39:47.1503444+00:00",
"duration": "00:00:00.0163775",
"success": false,
"responseCode": "404",
"url": "http://192.168.2.21:3000/api/employees(2L)",
"httpMethod": "GET",
"properties": {
"DeveloperMode": "true"
}
}
}
}
i'am new in this type of development,
it think it is by routing or filter,
Is there someone who can help me out of this problem
Kind regards
Roger
|
|
|
|
|
|
Thanks for the response,
you can see the working url coming from the restlet tool is different
"url": "http://192.168.2.21:3000/api/Employees/2" as the url from de odata client that i have made
"url": "http://192.168.2.21:3000/api/employees(2L)"
I made the REST server on the example www.youtube.com/watch?v=LpySuvYPMZQ">REST MySQL - Build a REST Service in Visual Studio 2015
in the client app i used
Application1.db.employees.byKey(e.itemIndex).done(function (data) {
employee.fromJS(data);
isReady.resolve();
});
my question is, where and how do i need to change my client app that the request of the oData client works with the REST server
modified 18-Nov-18 7:55am.
|
|
|
|
|
Hi,
Is there anyway, I can add all the dlls that are required for the application deployment be automatically added by Nuget, means when I am deploying the application, a tool that can warn me or let me know that this dll is missing from the deployment, if it can be done by nuget itself, it would be a great help.
I am asking this because a serious issue happened in my application deployment, reportviewerforMVC tool that uses the MicroSoft.Sql.Types dll was missing but deployment was happening, it took me considerably long time to identify what was the problem, because ReportViewerForMVC was not giving me any error message.
Please need some help any help would be very very greatful - thanks a lot friends.
modified 21-Nov-18 12:12pm.
|
|
|
|
|
I have InProc Session mode set to 20 min(web.config),
If the user is inactive after 20 min user gets logged off and that's fine but
i also want to check after 10min of user inactivity sql table value has to be updated.How to handle this?
|
|
|
|
|
Could take a look at web backgrounder https://github.com/NuGet/WebBackgrounder
Very basic and simple task runner. Check the related NuGet packages. For anything complex use quartz.net.
|
|
|
|
|