From: http://www.cnblogs.com/maniacstar/archive/2009/04/21/1440180.html
There are two ways to submit a single form: Get and post.CodeTo understand the differences between the two submission methods:
< Form ID = "Form1" Method = "Get" Runat = "Server" >
< Div >
Your name < ASP: textbox ID = "Name" Runat = "Server" > </ ASP: textbox > < BR />
< BR />
Your website < ASP: textbox ID = "Website" Runat = "Server" > </ ASP: textbox > < BR />
< BR />
< BR />
< ASP: button ID = "Button1" Runat = "Server" Text = "Send" /> < BR />
< BR />
< BR />
Learn request and response usage < BR />
< BR />
< BR />
</ Div >
</ Form >
< Form ID = "Form2" Method = "Post" Runat = "Server" >
< Div >
Your name < ASP: textbox ID = "Name2" Runat = "Server" > </ ASP: textbox > < BR />
< BR />
Your website < ASP: textbox ID = "Website2" Runat = "Server" > </ ASP: textbox > < BR />
< BR />
< BR />
< ASP: button ID = "Button2" Runat = "Server" Text = "Send" /> < BR />
< BR />
< BR />
Learn request and response usage < BR />
< BR />
< BR />
</ Div >
</ Form >
The difference can be seen from the URL. How can we program to receive data?
There are 1st types of data to be transmitted using the get method:
Code
Protected Void Page_load ( Object Sender, eventargs E)
{
String ID = Request. querystring [ " Name " ];
String Website = Request. querystring [ " Website " ];
Response. Write (ID + " <Br> " + Website );
Response. Write ("You are using" +Request. requesttype+ "Transmission data");
}
2nd. Write Method for receiving data transmitted using the POST method:
Code
Protected Void Page_load ( Object Sender, eventargs E)
{
String Id2 = Request. Form [ " Name2 " ];
String Website2 = Request. Form [ " Website2 " ];
Response. Write (Id2 + " <Br> " + Website2 );
Response. Write ("You are using" +Request. requesttype+ "Transmission data");
}
String ID4 = Request [ " Name4 " ];
String Website4 = Request [ " Website4 " ];
Response. Write (ID4 + " <Br> " + Website4 );
3rd types of code that accepts both the get and post methods for data transmission:
Write method
String ID3 = Request. Params [ " Name3 " ];
String Website3 = Request. Params [ " Website3 " ];
Response. Write (ID3 + " <Br> " + Website3 );
B Writing Method
String ID4 = Request [ " Name4 " ];
String Website4 = Request [ " Website4 " ];
Response. Write (ID4 + " <Br> " + Website4 );
The 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. However, the execution efficiency is better than the POST method.
Suggestion:
1. The get method is more secure than the POST method. If it contains confidential information, we recommend that you use the post data submission method;
2. We recommend that you use the get method when querying data. We recommend that you use the POST method when adding, modifying, or deleting data;