Part 143 Difference between http get and http post methods04:33

  • 0
Published on June 12, 2017

C#, SQL Server, WCF, MVC and ASP .NET video tutorials for beginners

HTTP stands for Hypertext Transfer Protocol. Http is the most common protocol used for communication between a web server and a client. For example, to request home page of Pragim Technologies, you would type the following URL. Notice that the URL has http prefix.

The 2 most commonly used HTTP methods are GET and POST.

Build the solution. Open a browser window. In the Address bar type the following address and press and enter key.

So here we are issuing a GET request for WebForm1.aspx. In the fiddler tool, you can clearly notice that a GET request is issued for WebForm1.aspx

At this point, you will have the user interface to enter FirstName, LastName and Email. Enter the details and when you click “Submit” button, the data will be posted to the server. So, here we are issuing a POST request to submit the data on WebForm1.aspx. In the fiddler tool, you can clearly notice that a POST request is issued to submit WebForm1 data.

In the Button1_Click() event handler, we have Response.Redirect() call, which issues a GET request to WebForm2.aspx

GET Request – GET Request is generally used to get data from the web server. A GET request is generally issued,
1. When you click on a hyperlink
2. When Response.Redirect() statement is executed
3. When you type URL in the address bar and hit enter

POST Request – POST request is generally used to submit data to the server. A POST request is generally issued,
1. When you click on a submit button
2. When AUTOPOST back is set true and when a selection in the DropDownList is changed

Difference between GET and POST method
1. GET method appends data to the URL, where as with the POST method data can either be appended to the URL or in the message body.
2. As GET request rely on querystrings to send data to the server, there is a length restriction, where as POST requests have no restrictions on data length.
3. While it is possible to change the state of data in database using GET request, they should only be used to retrieve data.

In asp.net webforms, IsPostBack page property is used to check if the request is a GET or a POST request. If IsPostBack property returns true, then we know the request is GET, else the request is POST.

Enjoyed this video?
"No Thanks. Please Close This Box!"