Distinguish the get and post methods in ASP. NET, asp. netget

Source: Internet
Author: User

Distinguish the get and post methods in ASP. NET, asp. netget

In web page design, the get method is the default, whether it is dynamic or static, and its URL length is limited. Therefore, the data that can be transmitted by the get request method is also limited, generally, the get method can transmit 256 bytes of data. When the length of data transmitted by the get request method cannot meet the requirements, another request method post is required, the maximum data that can be transferred by the post method is 2 MB. when reading the data transmitted by the post method, you must use the form method. When the post method is executed on the aspx page, the address bar does not see the transmitted parameter data, which is more conducive to page security. Therefore, the post method is generally used to transmit page data.

Here is a simple example:

Get Method

Html page:

<Html xmlns = "http://www.w3.org/1999/xhtml"> 

Send GET request

<Hr/> <form action = default7.aspx method = get> enter the sent content: <input type = text name = "content1"/> <br/> <input type = submit value = "send"/> </form> </center> </body> 

Corresponding aspx page:

<Html xmlns = "http://www.w3.org/1999/xhtml"> 

Receive content from the GET method:

<Hr/> <% string content = Request. queryString ["content1"]; Response. write ("the content sent by the GET method is:" + content); %> </center> </body> 

Post method

Html page:

<Html xmlns = "http://www.w3.org/1999/xhtml"> 

Send post request

Enter the sent content:

<Input type = text name = "content1"/> <br/> <input type = submit value = "send"/> </form> </center> </body> 

Corresponding aspx page:

<Html xmlns = "http://www.w3.org/1999/xhtml"> 

Receive content from the post method:

<Hr/> <% string content = Request. form ["content1"]; Response. write ("the content sent by the POST method is:" + content); %> </center> </body> 

In the get method, when the aspx page is executed, the address bar displays a section of characters "? Content1 = html input value ", but the post method is not displayed. In contrast, the post method is more secure and suitable.

The above is all the content in this article. You should understand the differences between the get method and the post method. I hope this article will be helpful for your learning.

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.