Talking about the order of the Request object acquiring client data in ASP

xiaoxiao2021-03-06  15

The Request object in the ASP is a very important object that gets the client's submission of data. Everyone is also very familiar with it.

Even so, some people often ask me what is the difference between the following ways, what should I write?

StrMessage = Request ("msg")

StrMessage = Request.form ("msg")

Moreover, I also read a lot of people written by the writings of Request (""), of course, such a writing is nothing wrong.

Just everyone should pay attention to the Request object has several collections to get the data submitted by the client, usually querystring, form, and servervariables.

No matter which collection, it can be obtained directly through Request (""), there is a problem, if the get mode and post method submit the same variable, such as username = CQQ, then you use Request ( "username") taken in the end is GET's data or POST's data?

So, the problem is here, everyone should think of it, Request is in order from these collections, and the order in the previous quarter is querystring, form, and finally ServerVariables. The Request object searches in this order searches the variables in these collections, and if there is any case, it will be in the back. Therefore, the above example request ("UserName") is actually submitted by the GET method.

So in order to improve efficiency, reduce unnecessary search time, but also for the procedure specification, it is recommended to use the request. The collection is better, such as Request.form ("UserName").

Here is a test example. After submission, everyone can add directly to the address? Username = test Test:

<%

IF Request ("Submit") <> ""

Response.write "Take directly:" & Request ("UserName") & "
"

Response.write "Take Get:" & Request.QueryString ("UserName") & "
"

Response.write "Take POST:" & Request.form ("UserName") & "
"

END IF

%>

Transfer from:

Http://www.contnew.com/tech/develop/asp/2004/10/18_413537_01.html

转载请注明原文地址:https://www.9cbs.com/read-47982.html

New Post(0)