Redirect to URL by HTTP_REFERER RRS feed

  • Question

  • User1864390977 posted

    Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    <o:p> </o:p>

    I have a problem with Request.ServerVariables("HTTP_REFERER")<o:p></o:p>

    I have 4 different places from which user can come on my utility page "pageUtil.aspx"<o:p></o:p>

    The URL is almost the same http://Computer/Folder1/Folder2/ <o:p></o:p>

    "Folder1" is different for those 4 places.<o:p></o:p>

    <o:p> </o:p>

    Now, when user comes to my pageUtil.aspx from each place I would like to grab URL using <o:p></o:p>

    Request.ServerVariables("HTTP_REFERER") and have a link on my pageUtil.aspx <o:p></o:p>

    If the user wants to return back he/she returns on the same page where they came from.<o:p></o:p>

    <o:p> </o:p>

    In this case I tried first using Request.ServerVariables("HTTP_REFERER") which didn’t work.<o:p></o:p>

    What happened was the first time through I got - "nothing" in<o:p></o:p>

    GetURL = Request.ServerVariables("HTTP_REFERER")<o:p></o:p>

    <o:p> </o:p>

    Second time through I got the URL of the page pageUtil.aspx<o:p></o:p>

    So for some reason HTTP_REFERER didn't want to take the URL of the previous page like it’s suppose to.<o:p></o:p>

    I was watching it and realized that first time trough the is nothing in there (almost like a skip)<o:p></o:p>

    In the beginning I thought it was like that because I was testing pageUtil.aspx separately. There would be no URL but then I tested it from links.<o:p></o:p>

    Still the same.<o:p></o:p>

    <o:p> </o:p>

    I tempararly soleved the problem passing the parameter but I still would like to know the answer as I would be using it again.<o:p></o:p>

    Thank you,<o:p></o:p>


    Monday, October 31, 2005 3:29 PM

All replies

  • User-294030300 posted


    Try the Request.UrlReferrer object, which has several properties to get at the name.

    Monday, October 31, 2005 4:10 PM
  • User1864390977 posted

    Thank You,
    This really helped, I already made all nes. changes and everything works fine.
    But then what is the different between

    GetURL = Request.UrlReferrer.ToString()


    GetURL = Request.ServerVariables("HTTP_REFERER")


    Wednesday, November 2, 2005 2:58 PM
  • User-294030300 posted

    I'm not sure exactly; I saw someone ask the same question before, and that was the response given, which solved their problem.  When possible, I would get away from using ServerVariables objects, because who knows how long they will be supported.

    Sorry I couldn't be more help on this.
    Monday, November 7, 2005 8:46 AM
  • User1864390977 posted
    Thank you.
    Wednesday, November 9, 2005 3:25 PM