The difference between ASP. NET Get and post two commits:

Source: Internet
Author: User
Tags html header id3
There are two ways to submit a single form, one for get, and one for post. Look at the following code to understand the difference between ASP. NET Get and post two commits:

< form id= "Form1" method= "Get" runat= "Server" >

< div>

Your name < Asp:textbox id= "name" runat= "Server" >

</asp:textbox>< br/>

< br/>

Your website < asp:textbox id= "website" runat= "server" ></asp:textbox>< br/>

< br/>

< br/>

< Asp:button id= "Button1" runat= "Server" text= "send"/>< br/>

< br/>

< br/>

Learn the usage of request and response < br/>

< br/>

< br/>

</div>

</form>

< form id= "Form2" method= "POST" runat= "Server" >

< div>

Your name < Asp:textbox id= "name2" runat= "Server" ></asp:textbox>< br/>

< br/>

Your website < asp:textbox id= "Website2" runat= "Server" ></asp:textbox>< br/>

< br/>

< br/>

< Asp:button id= "Button2" runat= "Server" text= "send"/>< br/>

< br/>

< br/>

Learn the usage of request and response < br/>

< br/>

< br/>

</div>

</form>

The difference between ASP. NET get and post can be seen from the URL. So how does the program implement 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 way to receive data transmitted using the POST method:

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 type of code that accepts both the get and post methods to transmit data:

A notation

String id3 = request.params["Name3"];

String website3 = request.params["Website3"];

Response.Write (ID3 + "< br>" + website3); B notation

String id4 = request["Name4"];

String website4 = request["Website4"];

Response.Write (Id4 + "< br>" + website4);

form submission, ASP. NET the difference between get and post methods is summarized as follows:

1. Get is the data that is fetched from the server and post is the data sent to the server.

2. Get is the URL where the parameter data queue is added to the Action property of the submission form, and the value corresponds to the field one by one in the form, which is visible in the URL. Post is the HTTP post mechanism that places the fields within the form with their contents in the HTML header, along with the URL address referred to by the Action property. The user does not see the process.

3. For Get mode, the server side uses Request.QueryString to get the value of the variable, and for post, the server side uses Request.Form to obtain the submitted data.

4. Get transmits a small amount of data, cannot be greater than 2KB. Post transmits a large amount of data, which is generally not restricted by default. In theory, however, the maximum amount 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 the security of the method is less than the post, including confidential information, it is recommended to use the Post data submission method;

2, when doing data query, it is recommended to use Get method, and in the data to add, modify or delete, it is recommended to use POST method.

  • 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.