Request| Object | client | Data on the order of the Request object in ASP to get the client data
/**
Description: Small issues to be aware of when using ASP request objects
Author: Ci Qin Qiang
Email:cqq1978@yeah.net
**/
The request object in ASP is a very important object to get the client to submit the data, everybody is very familiar to him too.
Even so, people often ask me how the following kinds of writing are different, in the end how to write?
strmessage = Request ("msg")
strmessage = Request.Form ("msg")
Also, I have seen many people write code, all are request (""), of course, this writing is not wrong.
It's just that people should pay attention
The request object has several collections to get the data submitted by the client, commonly used by Querystring,form and ServerVariables.
And no matter what kind of collection can actually be obtained directly from the request (""), there is a problem, if
Get way and Post method submitted the same variable, such as USERNAME=CQQ, then you use Request ("username")
Did you get the data that came out of you or did you post it?
So, the problem here, you should think of, request from these sets of data is in order, from the previous to
The order is querystring,form, and finally ServerVariables. The request objects are searched sequentially in this order
The variables in these sets, if they are met, are terminated, and the ones that follow are no more. So the above example request ("username")
The actual data that is submitted by the Get method is taken.
So in order to improve efficiency, reduce unnecessary search time, but also for the Code of Procedure, we suggest that we still use request. Collection of
The way is better, such as Request.Form ("username").
Here is a test example, after the submission, you can directly after the address of the add? USERNAME=AAA to test:
<%
If request ("submit") <> "then"
Response.Write "Direct fetch:" & Request ("username") & "<br>"
Response.Write "Fetch get:" & Request.QueryString ("username") & "<br>"
Response.Write "Take post:" & Request.Form ("username") & "<br>"
End If
%>
<form name=form1 action= "" method=post>
<input type=test name= "username" value= "Postuser" >
<input type=submit name= "Submit" value= "Test" >
</form>