Get vs. Post requests

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.