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.