Get and post differences and usage

Source: Internet
Author: User
Tags html header

A lot of people can't tell the difference between get and post, and when to use get? When do I use post?
Both get and post two methods send data to the server, but which one should you use?
The HTTP standard contains both methods for different purposes. Post is used to create the resource, and the contents of the resource are programmed into the HTTP instructions. For example, processing order forms, adding new rows of data to a database, and so on.
The Get method is used when a request has no side effects, such as a search, and the Post method is used when the request has side effects, such as adding data rows to the database. A more practical problem is that the Get method may produce a very long URL, perhaps exceeding the URL length limit for some browsers and servers.
Use the Post method if any of the following conditions are true:

The result of the request has a persistent side effect, for example, adding new rows of data within the database.
If you use the Get method, the data collected on the form may cause the URL to be too long.
The data to be transmitted is not in 7-bit ASCII encoding.

Use the Get method if any of the following conditions are true:

The request is to find the resource, and the HTML form data is used only to help search.
The result of the request has no persistent side effects.
The total length of the data collected and the input field names within the HTML form does not exceed 1024 characters.

The difference between get and post methods in form submission
1. Get is the data that is fetched from the server and post is the data sent to the server.

2. Get is the URL where the parameter data queue is added to the Action property of the submission form, and the value corresponds to the field one by one in the form, which is visible in the URL. Post is the HTTP post mechanism that places the fields within the form with their contents in the HTML header, along with the URL address referred to by the Action property. The user does not see the process.

3. For Get mode, the server side uses Request.QueryString to get the value of the variable, and for post, the server side uses Request.Form to obtain the submitted data.

4. Get transmits a small amount of data, cannot be greater than 2KB. Post transmits a large amount of data, which is generally not restricted by default. In theory, however, the maximum amount of IIS4 is 100KB in 80KB,IIS5.

5. Get security is very low, post security is high.

Get and Post methods in an HTML form form

in B/sApplication, the foreground and background data interaction is done through the form form in HTML. Form provides two ways to transfer data?? Get and post. Although they are all methods of data submission, they are quite different in actual transmission and can have a serious impact on the data. Although the Web container has shielded some of the differences for the convenience of getting variable values, it is also helpful to understand the differences between the two in future programming.
The Get and post methods in the form, respectively, correspond to the Get and post methods in the HTTP protocol during data transfer. The main differences are as follows:
1, get is used to obtain data from the server, and post is used to pass data to the server.
2. Get adds the data in the form in the form of Variable=value, followed by the URL to which the action points, and both use "?". connections, and each variable is connected by a "&" connection; Post is the data in the form that is placed in the data body of the forms, in the same way that the variables and values are passed to the URL that the action points to.
3, get is not safe, because in the transfer process, the data is placed in the requested URL, and now many existing servers,Proxy Serveror the user agent logs the request URL to a log file and places it somewhere so that some privacy information may be visible to third parties. In addition, users can alsoBrowserdirectly see the submitted data, some system internal messages will be displayed together in front of the user. All the actions of the post are not visible to the user.
4, get transmission of small amount of data, mainly because of the URL length limit, and post can transfer a lot of data, so inUploading filesYou can only use post (and of course there is one reason that will be mentioned later).
5. Get restricts the value of the data set for form forms to be ASCII characters, while Post supports the entire ISO10646 character set.
6, get is the default method for form.

Get and post differences and usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.