Difference between request. Form and request. querystring

Source: Internet
Author: User

ASP. form, both methods can obtain the parameter values passed by the page form. I have never noticed the difference between the two methods. I generally like to use the form of request ("ABC, simple and clear.

Recently I modified some kingcms code. One of the Code is the request. form ("ABC") is used to obtain the passed parameters. However, I can enter the passed parameters in the address bar and cannot obtain them through this code. After reading the code carefully, I find that, because of the request and request. this is caused by different forms.

First, the request itself is a static object of the system and can also be called as an array. For example, request ("ABC") is used to obtain the value corresponding to the "ABC" in the request array, this array is not fixed, but a collection of multiple arrays, including the values of the server variable arrays (querystring, form, cookies, clientcertificate, servervariables), that is, the request can traverse these arrays in sequence and return the corresponding values. It is very convenient to use once and for all.

Request. the form request member function is not so broad. It only takes values from the form array, that is, the input unit of the <form> label in the page table (for example, the value passed by <input type = text>. Then, you cannot obtain index. asp in the Link string through form? ABC = 123.

Another method is request. querystring ("ABC"). You can obtain the parameters passed by the querystring link string.

These three methods can be distinguished based on the transmission data mechanism of HTTP. Request. Form can obtain the data submitted in post mode, and requst. querystring can obtain the data submitted in get method, while request can obtain the data transmitted in both methods.

According to the transmitted data volume, request. Form can transmit unlimited data, while request. querystring can only transmit 2 k data volume.

According to the speed, request. qeurystring will be slightly faster than request. Form

It is the most convenient and best to use. Haha, the request itself is a direct one. No matter how data is transmitted, it can be obtained, and the performance is slightly reduced. However, for the current network and computer, it is negligible, so I like to write requests ("ABC ")

Summary;

1. Request. Form method, which is used to receive form variables (POST method)

2. Request. querystring method, which receives URL parameters (get method)

3. the request object may not specify the specific querystring or form method, such as request ("variable"), because it can be automatically identified, but it is better to specify it. Otherwise, it takes a little time to determine the execution efficiency of the program. Request: contains the preceding two methods (obtain the data submitted by the get method first), which are searched in querystring, form, and servervariable.

In addition to the different receipt methods, the two also have the problem of transferring the data size, request. there is no limit on the data that the form method can receive, but the request. querystring can only receive data smaller than 2 kb. Of course, the latter executes faster than the former. Generally, the request. querystring method is used for database query requests. because there are only a few keywords in the query, there is no need to use the request. Form method, which slows down the query speed. In addition, the request. querystring method also displays data in the address bar of the client browser, which is less secure. The request. Form method does not have any of the above questions. Therefore, it is widely used for data submission and user login in multiple text fields.

Difference between request. Form and request. querystring

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.