1. 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.
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.
Suggestion: In form, the POST method is recommended.
2. <form action = "" method = "Post"> A prompt box is displayed during refresh, asking whether to resend the request. If it is changed to method = Get, this prompt is not displayed, the following are some differences between post and get.
The post request has no length limit (at least theoretically)
Get has a length limit of up to 2048 bytes (1024 Chinese characters)
3. Do you still remember request. querystring ()? As long as the value is passed with get, it will be behind the HTTP request string! Try it! Post is not followed by the HTTP request string, but at the end of the request! And invisible. Generally, the password must be passed in like this. Otherwise, you can see it directly in the address bar !! (Although not encrypted)
There is also more post-uploaded content.
In other words, IIS filters generally only accept get parameters, which is why large search engines are followed by a lot of content, because post cannot be sent, and only get can be used. Check out Goole or Yahoo!
4. Differences between get and post methods in Form submission are summarized as follows:
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.
POST method considerations:
From a.html to ABC. aspx through form action = ABC. aspx and from HTML to aspx:
1. Use jquery post data:
$. Post ($ ( " # Txtaddress " ). Val (),
{
A: ' C ' ,
C: $ ( " # Txtcontent " ). Val ()
},
Function (data ){
$ ( " # Txtresult " ). Append ( ' <Div id = "d ' + ID + ' "Style =" height: ' + $ ( " # Txtresult " ). Height () + ' Px; "> <Div style =" display: none "id =" P ' + ID + ' "> ' + $ ( " # Content " , Data).html () + ' </Div> ' );
2. Request. Form ["The element name is not ID"]
A. html
< Form Action = " Test_post_to_aspx.aspx " Method = " Post " >
< Input type = " Text " Name = " Text " Value = " Ttttttttttttttttt " />
< Input type = " Submit " Name = " Submit " Value = " Submit " >
</Form>
ABC. aspx
Protected Void Page_load ( Object Sender, eventargs E)
{
String A = Request. Form [ " Text " ];
Response. Write ();
}
######################################## ########################
Procedure:
Both post and get are optional values of the form attribute method. The default value of method is get. The main differences between the two are:
1. on the client side, the get method submits data through the URL, as shown in address 1.4.3 in the address bar after submission.
Figure 1.4.3 address bar after the form is submitted in get Mode
The Location Bar remains unchanged after post is submitted, as shown in 1.4.4.
Figure 1.4.4 the address bar remains unchanged after the form is submitted in post mode.
2. on the server side, only request. querystring can be used to obtain data submitted in get mode. data submitted in post mode can only be obtained using request. Form:
Code
<% @ Language = " VBScript " CodePage = " 936 " %>
< Html >
< Head >
< Title > Test the form submission method </ Title >
< Meta HTTP - Equiv = " Content-Type " Content = " Text/html; charset = gb2312 " >
</ Head >
< Body >
< Form Method = " Post " Action = " <% = Request. servervariables ( " Script_name " ) %> " >
Submit data:
< Input name = " Ostr " Type = " Text " >
< BR >
Submission method:
< Select name = " Select " Onchange = " This. Form. method = This. Value " >
< Option value = " Post " Selected > Post </ Option >
< Option value = " Get " > Get </ Option >
</ Select >
< BR >
< Input type = " Submit " Name = " Submit " Value = " Submit " >
</ Form >
<%
If Request ( " Submit " ) <> "" Then
Response. Write " Pass " & Request. servervariables ( " Request_method " ) & " Data submitted in the following way: "
If Request. servervariables ( " Request_method " ) = " Get " Then
Response. Write Request. querystring ( " Ostr " )
Else
Response. Write Request. Form ( " Ostr " )
End If
End If
%>
</ Body >
</ Html >
Note: although the two submission methods can use request ("ostr") to obtain the submitted dataProgramEfficiency is affected and is not recommended.
Note
Run this example through IISCode(Use http: // localhost/method. for more information about IIS installation and configuration, see Section 4. Enter the submitted data and select post to submit. The result shown in Figure 1.4.4 is displayed. Select get to submit, as shown in Figure 1.4.3.
Note
In general, try to avoid using the get method to submit a form because it may cause security problems. For example, if you use the get method in the login form, the user name and password entered by the user will be exposed in the address bar. However, in the paging program, the get method is better than the POST method. Attribute explanation of the form used in this example (see Section 4 for ASP ):
Get adds the parameter to the address specified by the Action attribute and opens it as an anchor.
Post processes sent data through http post.