Url to current page

  • Thread starter Mats-Lennart Hansson
  • Start date
M

Mats-Lennart Hansson

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
 
M

Mats-Lennart Hansson

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
 
A

Aaron Bertrand [MVP]

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

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?).
 
R

Roland Hall

in message
: 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
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top