locked
Move to new server and Request.ServerVariables("QUERY_STRING") Now Returns Empty/Null Value RRS feed

  • Question

  • User-559443515 posted

    I have a custom error handling module for my site and it works fine on its current vps, which is setup with older versions of just about everything.  The site is being moved to a new vps and the code doesn't work on the new server. In tracking it down, the site is correctly routing to the 404.asp file (with ecinclude inc_404.asp) with use of a web.config file. Within the file, it performs a "Request.ServerVariables("QUERY_STRING")" to find out what page was requested and then handles it accordingly.  On the current server, it returns values like "404;http://www.sample.com:80/text_that_was_entered".  On the new server, it returns nothing.  So since it doesn't get a value, it can't parse it and determine what to do.

    Here's a portion of the code:

    ''Perform product/category check on requested page and generate / return if exists
    url=Request.ServerVariables("SERVER_NAME")
    qstring=Request.ServerVariables("QUERY_STRING")

    Note: the "SERVER NAME" request works fine on both.  But the value of "qstring" ends up as null/empty on the new server.

    I'm at a loss (and so are two different hosting companies that have attempted to move the sites to new servers) as to 1) what setting needs to be changed or 2) what version of what needs to be installed or 3) what code needs to change, to get the value to return.

    I'd greatly appreciate any help. I'm happy to look up any versions/settings that would help you help me.  Thanks!

    Wednesday, January 4, 2017 6:18 AM

All replies

  • User753101303 posted

    Hi,

    This is really a .asp page ??? It is configured at the IIS level on the old server? I'm not 100% sure but if it seems to remind me about something such as being able to redirect to a page with or without a querystring when configuring the error page.

    If configured at the IIS level I would check on the old server how it is configured.

    Wednesday, January 4, 2017 6:55 PM
  • User-559443515 posted

    Thank you for your reply.  It's a portion of the ASP VBScript page. There's more before/after this where it processes the value returned.  In continuing to research, I think it may actually be a problem with the web.config file. I think the way redirects are done may have changed. Here's a portion of the web.config directly related to the 404 error. I came across an article that sounds like the Redirect no longer keeps the original path, but clears it out. It suggested that with the new version of ASP.NET, that a Server.Transfer or Server.TransferRequest might be the right way do do this reroute and that those would keep the original path name. (reference: http://stackoverflow.com/questions/16054809/display-custom-asp-net-error-page-without-rewriting-url). But I'm not sure how to format that in the web.config file. Any suggestions or does this spur new thoughts?

    <?xml version="1.0" encoding="UTF-8"?>

    <configuration>
       <system.webServer>
          <httpErrors>
             <remove statusCode="404" subStatusCode="-1" />
             <error statusCode="404" prefixLanguageFilePath="" path="/404.asp" responseMode="Redirect" />
          </httpErrors>
       </system.webServer>
    </configuration>

    Wednesday, January 4, 2017 9:11 PM
  • User-2057865890 posted

    Hi Wmtricia,

    If responseMode is set to Redirect, the path value has to be an absolute URL, you could set responseMode to ExecuteURL. 

    <error statusCode="404" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" />

    reference: https://www.iis.net/configreference/system.webserver/httperrors

    Best Regards,

    Chris

    Thursday, January 19, 2017 8:23 AM