Difference between form method get and post

Source: Internet
Author: User

HTML form submission method
<Form action = "receive data page" method = "Post"> HTML forms use HTML controls.
For a common HTML form, it has two important attributes: Action and method. The action attribute specifies which of the following statements is used after the current form is submittedProgramThis processing program can be any dynamic web page or servlet or CGI (Common Gateway Interface). In Asp.net, it is generally processed by aspx pages. The method attribute specifies the form submission method. It has two possible values: Get and post.

 

Server form
Compared with HTML forms, server forms have one more runat = "server" tag, for example, <Form ID = "form1" runat = "server">
In the form on the server side, you do not need to specify the action attribute, indicating that the current page is used for processing. You can also choose not to specify the method attribute. By default, the form is submitted in post mode. In server forms, we can not only use HTML controls, but also HTML server controls and Asp.net controls. Note that there may be multiple
Runat = "server" indicates the form, but only one server form is allowed.

 

1. Get method:

<Form ID = "form1" runat = "server" method = "get">

 

Ii. Post method:

<Form ID = "form1" runat = "server" method = "Post">

It mainly depends on the changes in the address bar.

====================

 

Value

  Protected   Void Btnsubmit_click ( Object Sender, eventargs E)
{
// Request. form cannot get the value
// String strname = request. Form ["txtname"];
// String strpasword = request. Form ["txtpassword"];

// Request and request. querystring values can be obtained.
String Strname = Request [ " Txtname " ];
String Strpasword = Request [ " Txtpassword " ];
// String strname = request. querystring ["txtname"];
// String strpasword = request. querystring ["txtpassword"];
This . Label3.text = " User name: " + Strname +   " "   +   " Password: " + Strpasword; Server. Transfer ("info. aspx? Name = "+ strname +" & Password = "+ strpasword );
// Response. Redirect ("info. aspx? Name = "+ strname +" & Password = "+ strpasword );
}

 

Differences between server. Transfer and response. Redirect for page Jump

Redirect Mode

There is a difference between Chinese and numbers, and numbers are displayed directly. There is no difference between the Redirect get and post methods.

 

Transfer Mode

 
However, the transfer method, get and post methods are different. See the difference between get and post methods above. The default method is post.
==============================

Summary:
(1) The parameter names and parameter values are displayed in the address bar of the form submitted in get mode, but not in post mode.
(2) there is a limit on the maximum number of characters that can be entered in the address bar of the browser. Therefore, the get method cannot be used to submit a form with more parameter values, but the POST method does not.

 

The following common methods are used to obtain the value of a control (whether a server control or an HTML Control:

Obtaining Method Form submission method
Request. querystring ["Control name"] Suitable for forms submitted in get Mode
Request. Form ["Control name"] Suitable for forms submitted in post Mode
Request ["Control name"] Forms suitable for both get and post submission

From the above we can see that the request ["Control name"] method is feasible for both get and post methods, so we can use this method to handle all submitted forms.

 

 

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.