aspdotnet_request.md - brainchildservices/curriculum GitHub Wiki
Slide 1
How a request is processed - client and Server, HTTP GET AND POST
The Client is any tool that acts on the behalf of the user. This role is primarily performed by the Web browser. On the opposite side of the communication channel, is the server, which serves the document as requested by the client. Client and Server can be connected through different medium
- LocalHost
- LAN
- Internet
Slide 2
When we are creating a simple webapp, example an Area calculator app;
Here client and server is in same system.i.e; working as a LocalHost. Web browser with the local address as url (here localhost) act as client where the user can use Area Calculator. When getting Area calculated using the input values given by user, the system itself is the server.
To carry out this HTTP cycle of data , there needed to be the presence of different methods:
HTTP Methods called Get and Post , also called verb in a http request, are containing the code behind for http request and http response.
Slide 3
A Get request is generally used to get data from the web server.
when try to get the local razor page (here Area Calculator razor page ) from the browser we are actually make use of Get method. Using a Breakpoint at OnGet
method in our code behind page could make you understand this process
Slide 4
Reload your Area Calculator page and go to Network in Dev tools
- When breakpoint at
OnGet
got hit
Slide 5
- When Reload completed
Slide 6
A Post generally used to submit data to the server. A POST request is generally issued,
- When you click on a submit button
- When AUTOPOST back is set true and when a selection in the DropDownList is changed
The OnPost
handler method
is used for handling Form Submissions and the name of the OnPost
handler method
is specified on the Submit Button used to submit the Form using the asp-page-handler attribute in ASP.Net Core
Razor Pages.
when input your values and click on Submit button, you will get the method as Post in Dev toolbar
In asp.net core Response of our program can be viewed using Dev Toolbar with the values we have entered
Contents included in doc