Tip: Get client data using the Request object in ASP

Source: Internet
Author: User
Tags servervariables client
request| Objects | tips | client | data

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  "take 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.