The HTTP client methods Get and Post


Get and Post are methods used to send data to the server. Both methods are used in form data handling where each one has some difference on the way they work. It's important for you to know which method you are using.

Points of difference between Get and Post methods

Get method

  • It is used when the url is sent to the server.

  • The Get method is used to retrieve web pages from the server.

  • It is the first method. This is the default method for many browsers.

  • Get is also used to send user information from an online form on a web page to the server. Data is sent as a part of the URL in 'name-value' pairs.

  • Form data are restricted to ASCII codes.

  • There is a limitation on how much form data can be sent because URL lengths are limited.

  • With the Get method, the browser appends the data onto the URL.

  • All form data filled in is visible in the URL. Moreover, it is also stored in the user's web browsing history/logs for the browser.

  • Get method is less secure.

Post method

  • First request can't be Post.

  • You send data with Post request i.e. form information. Data will appear within message body.

  • It is sent in hidden (encrypted form)

  • Post is safer than Get

  • IT has large value sending option. Binary data, images and other files can all be submitted through METHOD=POST

  • With the Post method, the data is sent as standard input.

  • No default and should be Explicitly specified.

Lets see in more detailed about Get and Post methods

There is a character restriction of 255 in the URL. This is mostly the old browsers restriction and new ones can handle more than that. But we can't be sure that all our visitors are using new browsers. So when we show a text area or a text box asking users to enter some data, then there will be a problem if more data is entered. This restriction is not there in Post method.

In Get method data Gets transferred to the processing page in name value pairs through URL, so it is exposed and can be easily traced by visiting history pages of the browser. So any login details with password should never be posted by using Get method.

As the data transfers through address bar (URL) there are some restrictions in using space, some characters like ampersand (&) etc in the Get method of posting data. We have to take special care for encoding (while sending) and decoding (while receiving) data if such special characters are present.

However, one advantage of form data being sent as part of the URL is that one can bookmark the URLs and directly use them and completely bypass the form-filling process.

Please note that web forms in ASP.NET use Post by default. It can be changed into Get, but only for small forms. Web forms can Post a lot of data, especially when ViewState is involved.

Conclusion

I hope that this article would have helped you in understanding the HTTP client methods Get and Post. Please share it if you know more about this attribute. Your feedback and constructive contributions are welcome.


Similar Articles