There are 5 differences in the get post submission form in the asp tutorial. HTTP requests and forms are introduced separately. Friends in need can learn about the following five differences in the get post submission form in the asp tutorial.
There are 5 differences between Get and Post methods
1. Get is to obtain data from the server, and post is to transmit data to the server.
2. Get adds the parameter data queue to the URL pointed to by the ACTION attribute of the submitted form. The values correspond to each field in the form one-to-one and can be seen in the URL. Post uses the HTTP post mechanism to place each field in the form and its content in the HTML HEADER and transmit it to the URL address pointed to by the ACTION attribute. Users cannot see this process.
3. For the get method, the server side uses Request.QueryString to obtain the value of the variable. For the post method, the server side uses Request.Form to obtain the submitted data.
4. The amount of data transferred by get is small and cannot be larger than 2KB. The amount of data transmitted by post is relatively large and is generally unrestricted by default. But in theory, the maximum amount is 80KB in IIS4 and 100KB in IIS5.
5. The security of get is very low, and the security of post is high.
HTTP request: the difference between GET and POST methods
HTTP defines different methods of interacting with the server, the most basic methods are GET and POST. In fact GET is suitable for most requests, while POST is reserved only for updating the site. According to the HTTP specification, GET is used for information retrieval and should be safe and idempotent. Safe means that the operation is used to obtain information rather than modify it. In other words, GET requests should generally not have side effects. Idempotent means that multiple requests to the same URL should return the same result. The complete definition is not as strict as it seems. Basically, the goal is that when a user opens a link, she can be confident that the resource has not changed from her perspective. For example, the front page of a news site is constantly updated. Although the second request returns a different batch of news, the operation is still considered safe and idempotent because it always returns the current news. vice versa. POST requests are not so easy. POST represents a request that may change a resource on the server. Still taking the news site as an example, readers' annotations on the article should be implemented through POST requests, because the site is different after the annotation is submitted (for example, an annotation appears below the article);
When submitting a FORM, if Method is not specified, the default is a GET request, and the data submitted in the Form will be appended to the url, separated from the url by ?. Alphanumeric characters are sent as is, but spaces are converted to + signs and other symbols are converted to %XX, where XX is the ASCII (or ISO Latin-1) value of the symbol in hexadecimal. The data submitted by the GET request is placed in the HTTP request protocol header, while the data submitted by POST is placed in the entity data; the data submitted by GET can only be up to 1024 bytes, while POST does not have this limit.
What is the difference between using post and get in a form?
In Form, you can use post or get. They are all legal values of method. However, there are at least two differences in the use of the post and get methods:
1. The Get method passes user input through a URL request. The Post method takes another form.
2. When submitting in Get mode, you need to use Request.QueryString to obtain the value of the variable. When submitting in Post mode, you must access the submitted content through Request.Form.
Study the code below carefully. You can run it to get a feel for it:
code
The following is the quoted content:
<!--The only difference between the two Forms is the Method attribute-->
Copy the code code as follows:
<FORM ACTION=getpost.php tutorial METHOD=get>
<INPUT TYPE=text NAME=Text VALUE=Hello World></INPUT>
<INPUT TYPE=submit VALUE=Method=Get></INPUT>
</FORM>
<BR>
<FORM ACTION=getpost.php METHOD=post>
<INPUT TYPE=text NAME=Text VALUE=Hello World></INPUT>
<INPUT TYPE=submit VALUE=Method=Post></INPUT>
</FORM>
<? 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 ?>
illustrate
Save the above code as getpost.asp, and then run it. First test the post method. At this time, the browser's URL has not changed, and the returned result is:
The string passed through the Post method is: Hello World
Then the test is submitted using the get method. Please note that the browser url becomes:
http://localhost/general/form/getpost.php?Text=Hello+World
And the result returned is :
The string passed through the get method is: Hello World
Finally, submit it through the post method, and the browser url is still:
http://localhost/general/form/getpost.php?Text=Hello+World
And the returned result becomes :
The string passed through the get method is: Hello World
The string passed through the Post method is: Hello World
hint
Submitting data through the get method may cause security issues. For example, a landing page. When submitting data via the get method, the username 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 number and password from the browser's history. Therefore, in some cases, the get method can cause serious security problems.
suggestion
In Form, it is recommended to use the post method.