Monday, January 16, 2012

Basic difference on GET and Post HTTP methods

Please visit my new Web Site

Might be this the first interview question by the viva board. Which is very basic and you have to explain clearly. That's why i am trying to write the post "Basic difference between GET and POST method". Basically both method is used for submitting data into server. Read the differences from below:

Post Mechanism:
1. GET request is sent via URL.
2. Post request is sent via HTTP request body or you can say internally.

GET POST Difference
Figure: Get Method Indication

Sample Code:
<Form method="GET" Action="">
<input type="Text" name="Name" />
<input type="submit" value="Check" />

Form Default Method:
1. GET request is the default method.
2. You have to specify POST method within form tag like <Form method="POST".......

1. Since GET request is sent via URL, so that we can not use this method for sensitive data data.
2. Since Post request encapsulated name pair values in HTTP request body, so that we can submit sensitive data through POST method.

1. GET request has a limitation on its length. The good practice is never allow more than 255 characters.
2. POST request has no major limitation. Read discussion part later of this article.

Caching or Bookmarking:
1. GET request will be better for caching and bookmarking.
2. POST request has not.

1. GET request is SEO friendly.
2. POST request has not.

Data Type:
1. GET request always submitted data as TEXT.
2. POST request has no restriction.

Best Example:
1. SEARCH will be the best example for GET request.
2. LOGIN will be the best example for POST request.

HTTP Request Message Format:
GET /path/file.html?SearchText=Interview_Question HTTP/1.0
User-Agent: HTTPTool/1.0
[blank line here]

POST /path/script.cgi HTTP/1.0
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 8


Some comments on the limit on QueryString / GET / URL parameters Length:
1. 255 bytes length is fine, because some older browser may not support more than that.
2. Opera supports ~4050 characters.
3. IE 4.0+ supports exactly 2083 characters.
4. Netscape 3 -> 4.78 support up to 8192 characters.
5. There is no limit on the number of parameters on a URL, but only on the length.
6. The number of characters will be significantly reduced if you have special characters like spaces that need to be URLEncoded (e.g. converted to the '%20').
7. If you are closer to the length limit better use POST method instead of GET method.


Want to say something?

Want To Search More?
Google Search on Internet
Subscribe RSS Subscribe RSS
Article Categories
  • Gridview
  • Javascript
  • AJAX
  • Sql server
  • XML
  • CSS
  • Free Web Site Templates
  • Free Desktop Wallpapers
  • TopOfBlogs
    Free ASP.NET articles,C#.NET,VB.NET tutorials and Examples,Ajax,SQL Server,Javascript,Jquery,XML,GridView Articles and code examples -- by Shawpnendu Bikash