Copy codeThe Code is as follows: <form id = "form1" method = "get" runat = "server">
<Div> name <asp: TextBox ID = "name" runat = "server"> </asp: TextBox> <br/>
Your website <asp: TextBox ID = "website" runat = "server"> </asp: TextBox> <br/>
<Asp: Button ID = "Button1" runat = "server" Text = "send"/> <br/>
Learn request and response usage <br/>
</Div>
</Form>
<Form id = "form2" method = "post" runat = "server">
<Div> name <asp: TextBox ID = "name2" runat = "server"> </asp: TextBox> <br/>
Your website <asp: TextBox ID = "website2" runat = "server"> </asp: TextBox> <br/>
<Asp: Button ID = "Button2" runat = "server" Text = "send"/> <br/>
Learn request and response usage <br/>
<Br/>
</Form>
From the URL, we can see the difference between ASP. NET Get and Post. So how can we program the data reception?
There are 1st types of data to be transmitted using the get method:
Copy codeThe Code is as follows: 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 + "Data Transmission ");
}
2nd. Write Method for receiving data transmitted using the post method:
Copy codeThe Code is as follows: 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 + "Data Transmission ");
}
3rd types of code that accepts both the get and post methods to send data: Write
Copy codeThe Code is as follows: string id3 = Request. Params ["name3"];
String website3 = Request. Params ["website3"];
Response. Write (id3 + "<br>" + website3 );
B Writing Method
Copy codeThe Code is as follows: string id3 = Request. Params ["name3"];
String website3 = Request. Params ["website3"];
Response. Write (id3 + "<br>" + website3 );
B Writing MethodCopy codeThe Code is as follows: string id4 = Request ["name4"];
String website4 = Request ["website4"];
Response. Write (id4 + "<br>" + website4 );
In form submission, the difference between ASP. NET Get and Post methods is summarized as follows:
• Get is to get data from the server, and post is to send data to the server.
Get adds 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.
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.
The data size 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.
Get has low security and high post security. However, the execution efficiency is better than the Post method.
Suggestion:
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;
We recommend that you use the Get Method for Data Query. When adding, modifying, or deleting data, we recommend that you use the Post method.
It's not an alarm clock that wakes up every morning!