1.post Request
If the form is submitted as post, it must be received in Requert.form, and the form element must have a name attribute, and the name of the key specified by the form is the value of the Name property
1<form method="Get"action="accept.ashx">2User name: <input type="text"Name="txtname"Value=" "/><br/>3 4Password: <input type="Password"Name="txtpwd"/><br/>5<input type="Submit"Value="Submit"/>6</form>7 8 //The following is the Accept.ashx page9 Public voidProcessRequest (HttpContext context)Ten { OneContext. Response.ContentType ="Text/plain"; A //if the form is submitted as post, it must be received in Requert.form, and the form element must have a name attribute, and the name of the key specified by the form is the value of the Name property - stringUserName = context. request.form["txtname"]; - stringUserpwd = context. request.form["txtpwd"];
View Code
GET request
If it is a GET request, you must use QueryString when you receive it.
1<form method="Get"action="accept.ashx">2User name: <input type="text"Name="txtname"Value=" "/><br/>3 4Password: <input type="Password"Name="txtpwd"/><br/>5<input type="Submit"Value="Submit"/>6 7 //The following is the Accept.ashx interface8 //if it is a GET request, you must use QueryString when you receive it.9 stringUserName = context. request.querystring["txtname"];Ten stringUserpwd = context. request.querystring["txtpwd"]; OneContext. Response.Write ("User name is"+ UserName +"Password is"+userpwd); A -
View Code
Summarize:
1). If it is a POST request, then the data in the form will be placed in the request style, sent to the server, if the request is made in a get way, then the data in the form will be sent to the server in the URL address bar (note: The element must have the name attribute)
2). On the server receiving mode is not the same, if it is a POST request with Request.Form, if it is GET request with request.querystring;
3). Post requests are more secure than get requests, register logins, and so on with post submission.
4). The data sent by the POST request is larger than the GET request.
You can only submit the value value of the form element to the service side (SPAN,DIV, etc., which are not part of the form element, so cannot be submitted), and the form element must have the Value property
Get vs. Post requests