Difference between request. querystring and request. Params in Asp.net

Source: Internet
Author: User

Request. Form: Get the data submitted in post mode (receive the data submitted by form );

Request. querystring: Get the address bar parameters (data submitted in get Mode)

Request: contains the preceding two methods (obtain the data submitted by the get method first), which are searched in order in querystring, form, and servervariable.

And sometimes different results are obtained. If you only need a piece of data in form, but you use request instead of request. form, the program will also search for it in querystring and servervariable. If the same name exists in your querystring or servervariable, you don't get the expected value.

Request. params is a set of all post and get values. params is actually a set, which in turn includes request. querystring, request. form, request. cookies and requests. servervariable.

Difference between get post

1. Get is used to obtain data from the server, while post is used to transmit data to the server.
2. Get adds the data in the form to the URL pointed to by action in the form of variable = value, and the two use "?" And each variable is connected by "&". Post puts the data in the form data body and passes the data to the URL indicated by the action according to the corresponding variables and values.
3. Get is insecure because data is stored in the request URL during transmission, nowadays, many existing servers, proxy servers, or user proxies record the request URL to a log file and place it in a certain place, so that some private information may be seen by a third party. In addition, you can directly view the submitted data in the browser. Some internal messages are displayed in front of the user. All post operations are invisible to users.
4. Get transmission has a small amount of data, mainly because it is restricted by the URL length; while post can transmit a large amount of data, so only post can be used for uploading files (of course, there is another reason, as mentioned later ).
5. Get restricts that the dataset value of form forms must be ASCII characters, while post supports the entire iso000046 character set.
6. Get is the default form method.

 

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

Request. Params gets a set of items such as request. querystring and request. form.
Request. querystring: a collection of query strings such as URLs.
Request. Form: Used to accept variables such as form.

Request. querystring and request. Form are previously designed for ASP pages. When the form method attribute of an ASP page is get, querystring is used. When the form attribute is post, form is used.
The remaining one on the same floor

A calls B
Request. querystring:
A. asp: Response. Redirect "B. aspx? Id = 123"
B. asp: obtain the value of the data ID. Dim SID = request. querystring ("ID ")

Request. Form:
A. asp:
<Form>
...
<Asp: Text id = "pname".../>
...
</Form>
B. asp: obtain the value of the data ID. Dim sname = request. Form ("pname ")

Request. Params: method for obtaining parameters in. net. Which of the above two transmission methods can be used?
B. aspx. CS:
String SID = request. Params ("ID ")
String sname = request. Params ("pname ")

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.