Copy Code code 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 the usage of request and response < 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 the usage of request and response < br/>
< br/>
</form>
You can see the difference between asp.net get and post from the URL. Then how to program to achieve data reception?
1th, the way to receive data transmitted using the Get method:
Copy Code code 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 the" + Request.requesttype + "way to transmit data");
}
2nd, the method of receiving the data transmitted by post means:
Copy Code code 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 the" + Request.requesttype + "way to transmit data");
}
The 3rd type of code that accepts both get and post methods to transmit data: A notation
Copy Code code as follows:
String id3 = request.params["Name3"];
String website3 = request.params["Website3"];
Response.Write (ID3 + "< br>" + website3);
B Writing
Copy Code code as follows:
String id3 = request.params["Name3"];
String website3 = request.params["Website3"];
Response.Write (ID3 + "< br>" + website3);
B Writing
Copy Code code as follows:
String id4 = request["Name4"];
String website4 = request["Website4"];
Response.Write (Id4 + "< br>" + website4);
In form submission, ASP. NET get and post way to sum up the following points:
get is getting data from the server, and the post is sending data to the server.
Get is to add the parameter data queue to the URL that refers to the action attribute of the submission form, and the value corresponds to each field one by one in the form, as you can see in the URL. Post is the HTTP post mechanism that places the fields in the form and their contents in the HTML header to the URL address that the action attribute refers to. This process is not visible to the user.
For Get mode, the server end uses Request.QueryString to obtain the value of the variable, and for the Post method, the server end uses Request.Form to obtain the submitted data.
The amount of data transferred by get is small and cannot be greater than 2KB. Post transfers have a large amount of data, which is generally default to unrestricted.
Get security is very low, post security is high. But the execution efficiency is better than the Post method.
Suggestions:
The security of Get way is less than post method, including confidential information, it is recommended to submit the post data;
When making a data query, it is recommended to use Get method, while in doing data add, modify or delete, it is recommended to use POST method
Waking up every morning is not an alarm clock, it's a dream!