Url to current page

Discussion in 'ASP General' started by Mats-Lennart Hansson, May 10, 2004.

  1. Hi,
    I need to extract the url to the page I'm currently at. For example, if
    someone types http://www.mydomain.com/help/help.asp?param=1

    I want to extract all this. I've looked att HTTP_REFERER, but it only gives
    me the address from the page I came from (and it only exists if I clicked on
    a link to get here, not if I wrote it in the address bar).

    Any help is appreciated!

    Thanks,

    Mats-Lennart
     
    Mats-Lennart Hansson, May 10, 2004
    #1
    1. Advertising

  2. Mats-Lennart Hansson

    Dominique Guest

    urLocation = Request.serverVariables("SCRIPT_NAME") & "?" &
    Request.Querystring

    "Mats-Lennart Hansson" <> wrote in message
    news:%...
    > Hi,
    > I need to extract the url to the page I'm currently at. For example, if
    > someone types http://www.mydomain.com/help/help.asp?param=1
    >
    > I want to extract all this. I've looked att HTTP_REFERER, but it only

    gives
    > me the address from the page I came from (and it only exists if I clicked

    on
    > a link to get here, not if I wrote it in the address bar).
    >
    > Any help is appreciated!
    >
    > Thanks,
    >
    > Mats-Lennart
    >
    >
     
    Dominique, May 10, 2004
    #2
    1. Advertising

  3. Request.serverVariables("SCRIPT_NAME")

    only returns /help/help.asp. In my case, I also need
    http://www.mydomain.com. I did like this,

    "http://" & Request.ServerVariables("SERVER_NAME") &
    Request.ServerVariables("PATH_INFO") & "?" & Request.QueryString

    Will this always work, or are there hidden problems? Is there an easier way?

    Thanks,
    Mats-Lennart

    "Dominique" <> wrote in message
    news:c7nc4m$l1v$...
    > urLocation = Request.serverVariables("SCRIPT_NAME") & "?" &
    > Request.Querystring
    >
    > "Mats-Lennart Hansson" <> wrote in message
    > news:%...
    > > Hi,
    > > I need to extract the url to the page I'm currently at. For example, if
    > > someone types http://www.mydomain.com/help/help.asp?param=1
    > >
    > > I want to extract all this. I've looked att HTTP_REFERER, but it only

    > gives
    > > me the address from the page I came from (and it only exists if I

    clicked
    > on
    > > a link to get here, not if I wrote it in the address bar).
    > >
    > > Any help is appreciated!
    > >
    > > Thanks,
    > >
    > > Mats-Lennart
    > >
    > >

    >
    >
     
    Mats-Lennart Hansson, May 10, 2004
    #3
  4. > Will this always work, or are there hidden problems? Is there an easier
    > way?


    Sometimes, users will access the server by a SERVER_NAME that you are not
    expecting. For example, they could access it by IP address, or someone
    inside your network could access it by network name. Also, someone could
    modify their hosts file, and reference your server by whatever name they
    want to (e.g. http://this.server.sucks.com/)...

    If this is a problem, you could consider storing the domain name section as
    a constant (does it REALLY need to be dynamic?).

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/
     
    Aaron Bertrand [MVP], May 10, 2004
    #4
  5. Mats-Lennart Hansson

    Roland Hall Guest

    "Mats-Lennart Hansson" wrote in message
    news:%...
    : Request.serverVariables("SCRIPT_NAME")
    :
    : only returns /help/help.asp. In my case, I also need
    : http://www.mydomain.com. I did like this,
    :
    : "http://" & Request.ServerVariables("SERVER_NAME") &
    : Request.ServerVariables("PATH_INFO") & "?" & Request.QueryString
    :
    : Will this always work, or are there hidden problems? Is there an easier
    way?

    Mats-Lennart...

    Why do you need the full URL?

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, May 10, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. teej
    Replies:
    1
    Views:
    554
  2. Replies:
    0
    Views:
    469
  3. Jack
    Replies:
    3
    Views:
    672
    Tad J McClellan
    Dec 22, 2008
  4. Replies:
    3
    Views:
    418
  5. Replies:
    1
    Views:
    328
    Thomas 'PointedEars' Lahn
    Mar 19, 2008
Loading...

Share This Page