Home > Backend Development > C#.Net Tutorial > The difference between ASP.NET Get and Post submissions:

The difference between ASP.NET Get and Post submissions:

巴扎黑
Release: 2016-12-20 09:23:43
Original
1555 people have browsed it

There are two ways to submit a single form, one is the get method and the other is the post method. Look at the following code to understand the difference between ASP.NET Get and Post submissions:

  < 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 how to use request and response< br />

 

  < /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 how to use request and response< br />

 ; br />

 < /div>

 < /form>

  The difference between ASP.NET Get and Post can be seen from the URL. So how to program to receive data?

The way to receive the data transmitted by the get method is:

protected void Page_Load(object sender, EventArgs e)

"website"];

 Response.Write(id + "< br>" + website);

 Response.Write("You are using the " + Request.RequestType + "method to transmit data");

  }

 The second way to receive data transmitted by 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 + "method to transmit data") ;

  }

  string id4 = Request["name4"];

 string website4 = Request["website4"];

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

  3rd A way to write code that accepts both get and post methods to transmit data at the same time:

 A writing method

 string id3 = Request.Params["name3"];

 string website3 = Request.Params["website3"];

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

 In form submission, the differences between ASP.NET's Get and Post methods are summarized as follows:

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

 2. Get adds the parameter data queue to the URL pointed to by the ACTION attribute of the submitted form. The value corresponds to each field in the form and can be seen in the URL. Post uses the HTTP post mechanism to place each field in the form and its content in the HTML HEADER and transmit it to the URL address pointed to by the ACTION attribute. Users cannot see this process.

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

 4. The amount of data transmitted by get is small and cannot be larger than 2KB. The amount of data transmitted by post is relatively large and is generally unrestricted by default. But in theory, the maximum amount is 80KB in IIS4 and 100KB in IIS5.

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

Suggestions:

1. The get method is less secure than the Post method. If confidential information is included, it is recommended to use the Post data submission method;

 2. When doing data query, it is recommended to use the Get method; when doing data addition, modification or deletion, it is recommended to use the Post method.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template