Is this a bug?

L

Lei Wu

The following ASP script will display "C:\WINNT\TEMP" on my server:

<%=Request("temp")%>

Is is a bug, or something by design?

The server is a Windows 2000 SP4 running IIS5.

Thanks in advance.

Lei
 
B

Bob Barrows

Lei said:
The following ASP script will display "C:\WINNT\TEMP" on my server:

<%=Request("temp")%>

Is is a bug, or something by design?

The server is a Windows 2000 SP4 running IIS5.

Thanks in advance.

Lei
It is by design. When you don't specify the collection that contains the
variable whose value you want, it searches ALL the collections contained by
the Request object until it finds a variable of that name. That is why you
need to ALWAYS specify the collection you want to use:
<%=Request.querystring("temp")%>
or
<%=Request.Form("temp")%>
or
<%=Request.ServerVariables("temp")%>

HTH,
Bob Barrows
 
A

Aaron Bertrand - MVP

The following ASP script will display "C:\WINNT\TEMP" on my server:
<%=Request("temp")%>

Is is a bug, or something by design?

No, this is not a bug.

Using request("") alone is both inefficient and dangerous. First, it will
search /all/ request.* collections until it finds a match. And, if you use
a name that exists in more than one collection, you might get invalid
data...

Use the actual collection you are referring to (e.g. .form, .querystring)
instead of the lazy request("").

In this case, it is actually using Request.ServerVariables.

See http://www.aspfaq.com/2111 for more information.
 
V

vivek

Actually i had the same problem before, but it was doing only one of my
servers and not on the other ones. why would it do it different - its the
exact same code???

Vivek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top