Asp. Use of Get and post in net

Source: Internet
Author: User
Tags html header http post id3

ASP tutorial use of Get and post in. Net

In form submission, the difference between get and post in the ASP.net tutorial is summed up in the following ways:

1. Get is to obtain data from the server, post is to transfer data to the server.

2. Get is to add the parameter data queue to the URL of the action attribute that submits the form, and the value corresponds to each field one by one in the form, which can be seen 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.

3. For Get way, server end uses Request.QueryString to obtain variable value, for post way, server end uses Request.Form to obtain the submitted data.

4. 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. In theory, however, the maximum number of IIS4 is 100kb in 80KB,IIS5.

5. Get security is very low, post security is high. But the execution efficiency is better than the Post method.

Suggestions:

1, get mode of security is less than the Post method, including confidential information, the proposed use of post data submission method;

2, in doing the data query, it is recommended to use get way, while doing data add, modify or delete, it is recommended to use the Post method.


/* The difference between asp.net get and post can be seen from the URL. Then how to program to achieve data reception?
1th, the way to receive data transmitted using the Get method:
*/

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:

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");

}

String id4 = request["Name4"];
String website4 = request["Website4"];
Response.Write (Id4 + "< br>" + website4);

The 3rd kind of code that accepts both get and post methods to transfer data:
A notation

String id3 = request.params["Name3"];
String website3 = request.params["Website3"];
Response.Write (ID3 + "< br>" + website3);

b Writing

String id4 = request["Name4"];
String website4 = request["Website4"];
Response.Write (Id4 + "< br>" + website4);

Msdn:request objectrequest
Request.Form: Gets the data submitted as post (receives the data submitted by Form);
Request.QueryString: Gets the Address bar parameter ( Data submitted in Get method
Request: The data that is submitted in both of these ways (take precedence for getting method submissions) is searched sequentially in QueryString, form, and servervariable. And sometimes you get different results. If you only need one of the data in a form, but you use request instead of Request.Form, then the program will also be searched in QueryString, servervariable. If it happens that you have the same name in your querystring or servervariable, you will not get the value you originally wanted. The
Request.params is a collection of all post and get-pass values, Request.params is actually a collection, which in turn includes Request.QueryString, Request.Form, Request.Cookies and Request.servervariable.

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.