what is difference b/w get and post method in asp.net?
Get - Creats a Query string collection(did not store URL History, Data r visible in URL)
Post - Creates a Form Collection(Stroe URL history, Data r not visible in URL)
Sends values through the URL, we can use BACK, FORWARD of the IE, it wont give any warning, because all values stored in the URL, it will be in the history.
Values posting through form object, we can’t see the values in URL, also if we click BACK or FORWARD, it fill give the warning message, (like do you want to resend the values again?)
There is a limitation while sending the data; we can’t send very huge data, because the URL can not carry huge data.
We can send very huge data, because no URL is used.
Post and Get are the two main methods used in passing requests from the browser to the web server.
By default GET Method is used, meaning that all the information that needs to be sent about the resource is sent via the URL (and appears in the location bar of your browser). Any additional values - like field values are sent as name/value pairs appended to the end of the URL.
Example :The Google search engine is a good eg of using GET method sending name value pairs: http://www.google.com/search?q=HTML+.Net this gives us a search result of pages matching the search request "HTML .Net").
POST method on the other hand has only the URL of the page requested in the location bar, but it sends all other information - like field values, in the body of the [http request].
If we submit GET request multiple times, then we get the same results back which is is called an idempotent request.
Where as with a POST request, the results can be different each time.
Both POST and GET method can be used in form submission,but below are the few points to rem.
1st How much data (name/value pairs) are we sending? GET has a limited length (some browsers as low as 256 bytes), POST has no restrictions other than the time a request takes to timeout on the users browser.
2nd How sensitive is the data? GET stores the field values in name/value pairs in the URL, so if there's data you don't want there, use a POST instead. (Beware, this doesn't mean it is safe to send credit card numbers using a post method on an unsecure connection - POST doesn't encrypt. SSL is mandatory for this sort of data).
3rd. How useful would it be to link to the results of a request? If you want to allow people to bookmark the results of a request, then use a GET method (all good search engines use get for their request forms).
Is one of the fields a file/ are you uploading a file? Use a POST.
Get and Post are methods used to send data to the server With the Get method, the browser appends the data onto the URL. With the Post method, the data is sent as "standard input." The Get method is the default, so if you do not specify a method, the Get method will be used automatically. The Get method has several disadvantages: There is a limit on the number of characters which can be sent to the server, generally around 100 - 150 characters. Your user will see the "messy codes" when the data is sent. The Bottom Line is With the Get method, your users will see the "messy codes" in the Location box when they submit a form. With the Post method, they won't Use GET: - during development for debugging purposes - if you want your visitors to be able to bookmark the submitted pages - if you want to refer to submitted pages using hyperlinks Use POST: - for forms with password fields - for large forms or forms with large text fields