Difference between get and post

Source: Internet
Author: User
Tags html header

Source: difference between get and post

 

1. Get is to get data from the server, and post is to send data to the server.

2. Get is to add the parameter data queue to the URL referred to by the Action attribute of the submission form. The values correspond to each field in the form one by one and can be seen in the URL. Post uses the http post mechanism to place fields in the form and their content in the HTML header and send them to the URL address referred to by the Action attribute. You cannot see this process.

3. For the get method, the server uses request. querystring to obtain the value of the variable. For the POST method, the server uses request. Form to obtain the submitted data.
4. The data volume transmitted by get is small and cannot exceed 2 kb. The amount of data transmitted by post is large, which is generally not restricted by default. Theoretically, the maximum size of IIS4 is 80 KB, and that of iis5 is 100kb.
5. Low get security and high post security.
 
@ HTTP Request: difference between get and psot

HTTP defines different methods for interaction with the server. The most basic methods are get and post. In fact, get applies to most requests, while retaining post is only used to update sites.
According to the HTTP specification, get is used to obtain information, and should be secure and idempotent. The so-called security means that this operation is used to obtain information instead of modifying information. In other words, get requests generally do not produce side effects. Idempotence means that multiple requests to the same URL should return the same result. The complete definition is not as strict as it looks. Basically, the goal is that when a user opens a link, she can be confident that the resource has not changed from her own perspective. For example, the front pages of news sites are constantly updated. Although the second request will return a different batch of news, this operation is still considered safe and idempotent because it always returns the current news. And vice versa. POST requests are not that easy. Post indicates a request that may change resources on the server. Taking the news site as an example, the reader's comments to the article should be implemented through the POST request, because the site is already different after the annotation is submitted (for example, an annotation appears below the article ).
If method is not specified during form submission, the default value is get. The data submitted in form will be appended to the URL? Separated from the URL. The letter and number characters are sent as they are, but spaces are converted to "+". Other symbols are converted to % xx, XX represents the ASCII (or ISO Latin-1) value in hexadecimal notation. The data to be submitted for the GET request is placed in the HTTP Request Header, while the data to be submitted by post is placed in the object data.
Data submitted in get mode can contain a maximum of 1024 bytes, whereas post mode does not.
 
@ What is the difference between using post and get in a form?
 
In form, you can use post or get. They are all valid values of method.
However, the post and get methods are at least two different in use:
1. The get method transmits user input through URL requests. The post method is in another form.
2. You need to use request. querystring to obtain the value of the variable for get-based submission. When using post-based submission, you must use request. Form to access the submitted content.

Study the following code carefully. You can run it to feel it:

Code
<! -- Two forms have different method Attributes -->
<Form action = "getpost. asp" method = "get">
<Input type = "text" name = "text" value = "Hello World"> </input>
<Input type = "Submit" value = "method = get"> </input>
</Form>
<Br>
<Form action = "getpost. asp" method = "Post">
<Input type = "text" name = "text" value = "Hello World"> </input>
<Input type = "Submit" value = "method = post"> </input>
</Form>

<Br>
<Br>

<% If request. querystring ("text") <> "" Then %>
The string passed through the get method is: "<B> <% = request. querystring (" text ") %> </B>" <br>
<% End if %>

<% If request. Form ("text") <> "" Then %>
The string passed through the POST method is: "<B> <% = request. Form (" text ") %> </B>" <br>
<% End if %>

Description
Save the above Code as getpost. asp and run it. First test the POST method. At this time, the URL of the browser does not change, and the returned result is:
The string passed through the POST method is: "Hello World"
Then test the submission using the get method. Note that the URL of the browser is changed:

Http: // localhost/General/form/getpost. asp? TEXT = Hello + world

The returned result is:
The string passed through the get method is: "Hello World"
Finally, submit the file through the POST method. The URL of the browser is:

Http: // localhost/General/form/getpost. asp? TEXT = Hello + world

The returned result is:
The string passed through the get method is: "Hello World"
The string passed through the POST method is: "Hello World"

Prompt
Submitting data through the get method may cause security issues. For example, a login page. When you submit data using the get method, the user name and password will appear on the URL. If:
1. the login page can be cached by the browser;
2. Others can access the customer's machine.
Then, others can read the customer's account and password from the browser's history. Therefore, in some cases, the get method may cause serious security problems.
In form, the POST method is recommended.

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.