Is this a bug?

Discussion in 'ASP General' started by Lei Wu, Aug 7, 2003.

  1. Lei Wu

    Lei Wu Guest

    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
     
    Lei Wu, Aug 7, 2003
    #1
    1. Advertisements

  2. Lei Wu

    Bob Barrows Guest

    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
     
    Bob Barrows, Aug 7, 2003
    #2
    1. Advertisements

  3. Lei Wu

    Ray at Guest

    Ray at, Aug 7, 2003
    #3
  4. The following ASP script will display "C:\WINNT\TEMP" on my server:
    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.
     
    Aaron Bertrand - MVP, Aug 7, 2003
    #4
  5. Lei Wu

    vivek Guest

    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
     
    vivek, Aug 7, 2003
    #5
  6. Actually i had the same problem before, but it was doing only one of my
    Different versions of IIS, perhaps, process the request collections in a
    different order. See
    http://msdn.microsoft.com/library/en-us/iisref/htm/ref_vbom_reqo.asp
     
    Aaron Bertrand - MVP, Aug 7, 2003
    #6
  7. Lei Wu

    vivek Guest

    vivek, Aug 7, 2003
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.