Form submission

Form has two more special properties, is a Method, a method for transmitting HTTP predetermined form (to submit the form); there is a Action, when submitting data is predetermined where to send the form (to submit forms of address). Form functional form (submit) an automatic submission sometimes do not automatically submit written submission. Default can not write. If you do not want to automatically submit the form should write method to prevent automatic submission of the form (οnsubmit = "return false;" ).
There are two forms of submission: namely, get submitted (presented in a way as a form of default) submit post.
First, get submitted, the parameters will be submitted when get direct exposure to the URL. The following figure:
Here Insert Picture DescriptionHere Insert Picture Description
the value corresponding to the input form Form, and then click the form is submitted, it will be added to the URL of the form data after submission pointed, with links between the two, with each variable between the "?" "&"link.
Get to submit more simple and faster and can be used in most cases, but you can not use (it is best not to use) in the following situations:
First, the cache file is not available at the time of submission of the time;
two, to send a large number of servers when data (get submitted data volume restrictions);
Third, when a user sends an unknown character input (get submitted is unsafe);
Fourth, the file on the server will be updated when the database.
The next post is submitted: post submission is a form of data on the data form the body. FIG follows:
Here Insert Picture Description
enter a value corresponding to the form, and then click the form submission, submission after it will form data into the body data, the spread in the manner pointed object variables and values action (i.e. Controller ), then to the controller breakpoint to see the value of the page form input. As shown below:Here Insert Picture Description
On the left is the code, the right is the value after the break to see. Just send the URL and the form data when the form is submitted on a URL, no other values or other parameters. Post needs special note is then refresh the page after submitting duplicate data submitted will have adverse consequences, as shown below: Here Insert Picture Description
If you repeatedly refresh the page server will repeatedly reminded the information on the map, will make people feel very upset, this is not it the most good point.
The main difference between the Get and Post:
. 1, Get method is used to obtain data on the server; and Post is transmitted to modify data on the server Ziang.
2, the two way transmission parameters are not the same, the Get data is added directly to the rear URL action points; and Post, the body data in form of data.
3, Get is unsafe, because the process of data transfer data directly exposed on the requested URL, the user can see the data submitted in the browser, as well as some internal system information is also displayed in front of the user; and All user Post operations are not visible.
4, Get submit less data transmission, subject to limiting the length of the URL; and limiting the amount of data without Post submitted.
5, Get submission after obtaining data refresh does not have a negative impact; and Post refresh the page to submit duplicate submission could have adverse consequences.
Post acquired form element in four ways:
first: FormCollection from;
second: Request.Form [ "txtName"] ( txtName is the value of the name attribute of the form element); third: passing parameters through the form receiving form elements;
fourth solid model is received instantiated object, to accept the form elements by instantiating objects.
Get form elements get only one way, that is, to accept the form elements in the form of passing parameters.

Guess you like

Origin blog.csdn.net/weixin_44560796/article/details/90273016