The order in which the request object obtains client data in ASP

Source: Internet
Author: User
Tags servervariables client
Request| Object | client | Data in ASP the request object is a very important object to obtain the client submitting data, and we are very familiar with it.

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 you should pay attention to the request object has several sets to obtain the data submitted by the client, commonly used Querystring,form and ServerVariables.

And no matter what kind of collection can actually be obtained directly from the request (""), there is a problem here, if the Get method 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, we should think of, request from these several sets of data is in order, the former to the following order is Querystring,form, and finally is servervariables. The request object, in this order, searches for the variables in these sets, and if there is a match, the rest is terminated. So the above example request ("username") takes the actual data submitted by the Get method.

Therefore, in order to improve efficiency, reduce the unnecessary search time, but also for the Code of Procedure, we suggest that we still use request. The way to assemble 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=test 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>

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.