Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 07:28 AM
Lei Wu
Guest
 
Posts: n/a
Default Is this a bug?

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
  #2  
Old July 19th, 2005, 07:28 AM
Bob Barrows
Guest
 
Posts: n/a
Default Re: Is this a bug?

Lei Wu wrote:[color=blue]
> 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[/color]
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


  #3  
Old July 19th, 2005, 07:28 AM
Ray at
Guest
 
Posts: n/a
Default Re: Is this a bug?

No, it's not a bug. It's returning the server variable TEMP. When you call
Request(something), the server doesn't know if you mean, request.form,
cookies, certificates, etc., so it looks through ALL the collections in this
order:

QueryString
Form
Cookies
ClientCertificate
ServerVariables

Always specify what you mean if you want expected results.

http://msdn.microsoft.com/library/de..._vbom_reqo.asp

Ray at work

"Lei Wu" <marathoner@sina.com> wrote in message
news:5929ac79.0308070552.44aaf92a@posting.google.c om...[color=blue]
> 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[/color]


  #4  
Old July 19th, 2005, 07:28 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Is this a bug?

> The following ASP script will display "C:\WINNT\TEMP" on my server:[color=blue]
>
> <%=Request("temp")%>
>
> Is is a bug, or something by design?[/color]

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.



  #5  
Old July 19th, 2005, 07:28 AM
vivek
Guest
 
Posts: n/a
Default Re: Is this a bug?

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

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:umPCIvOXDHA.652@tk2msftngp13.phx.gbl...[color=blue]
> No, it's not a bug. It's returning the server variable TEMP. When you[/color]
call[color=blue]
> Request(something), the server doesn't know if you mean, request.form,
> cookies, certificates, etc., so it looks through ALL the collections in[/color]
this[color=blue]
> order:
>
> QueryString
> Form
> Cookies
> ClientCertificate
> ServerVariables
>
> Always specify what you mean if you want expected results.
>
>[/color]
http://msdn.microsoft.com/library/de...us/iisref/htm/
ref_vbom_reqo.asp[color=blue]
>
> Ray at work
>
> "Lei Wu" <marathoner@sina.com> wrote in message
> news:5929ac79.0308070552.44aaf92a@posting.google.c om...[color=green]
> > 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[/color]
>
>[/color]


  #6  
Old July 19th, 2005, 07:28 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Is this a bug?

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

Different versions of IIS, perhaps, process the request collections in a
different order. See
http://msdn.microsoft.com/library/en..._vbom_reqo.asp


  #7  
Old July 19th, 2005, 07:28 AM
vivek
Guest
 
Posts: n/a
Default Re: Is this a bug?

very interesting, thanks Aaron

Vivek

"Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
news:#JjVX1OXDHA.2620@TK2MSFTNGP09.phx.gbl...[color=blue][color=green]
> > 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[/color][/color]
the[color=blue][color=green]
> > exact same code???[/color]
>
> Different versions of IIS, perhaps, process the request collections in a
> different order. See
> http://msdn.microsoft.com/library/en..._vbom_reqo.asp
>
>[/color]


 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles