Post and Get of Asp.net

Source: Internet
Author: User

 

There are two ways to submit a form. One is the get method and the other is the post method. Let's look at the following code and understand the difference between the two submission methods:

Get method Transfer
<Html xmlns = "http://www.w3.org/1999/xhtml"> 
Public partial class Default3: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {string id = Request. queryString ["name"]; string website = Request. queryString ["website"]; Response. write ("input id is" + id); Response. write ("<br>"); Response. write ("input name" + website );}}
Post method Transfer
<Html xmlns = "http://www.w3.org/1999/xhtml"> 
Public partial class Default3: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {string id = Request. form ["name"]; string website = Request. form ["website"]; Response. write ("input id is" + id); Response. write ("<br>"); Response. write ("input name" + website );}}

Urlhttp: // localhost: 1092/SlwyWeb/Default3.aspx of the get method? _ VIEWSTATE = % 2fwepdwuklt1_otizodqwnwrk2hgzoy1tun1xdnu % 2BUD9XgpNyjdfyAmJtrK % 2Fh2qQ9sa4% 3D & name = 12 & website = 12 & Button1 = send

Post method Urlhttp: // localhost: 1092/SlwyWeb/Default3.aspx? Name = & website = & Button1 = send

It can be seen that the value of the post method is not stored in the url.

So where is the value of the post method stored?

Why is there a _ VIEWSTATE = % 2fwepdwuklt1_otizodqwnwrk2hgzoy1tun1xdnu % 2BUD9XgpNyjdfyAmJtrK % 2Fh2qQ9sa4% 3D string in the get Method url?


1. get is to add the parameter data queue to the URL referred to by the ACTION attribute of the submission form. The values correspond to each field in the form one by one and can be seen in the URL. Post uses the HTTP post mechanism to place fields in the form and their content in the html header and send them to the URL address referred to by the ACTION attribute. You cannot see this process.
2. For the get method, the server uses Request. QueryString to obtain the value of the variable. For the post method, the server uses Request. Form to obtain the submitted data.
3. The data volume transmitted by get is small and cannot exceed 2 kb. The amount of data transmitted by post is large, which is generally not restricted by default. Theoretically, the maximum size of IIS4 is 80 KB, and that of IIS5 is 100KB.
4. Low get security and high post security. However, get is more efficient than Post.

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.