get current address in ASP

liunx

Guest
i know this may be simple, but is there any way to get the current address you are looking at in ASP?either one of these...

Request.ServerVariables("PATH_INFO")
E.G. /servervars.asp
Request.ServerVariables("PATH_TRANSLATED")
E.G. c:\inetpub\wwwroot\servervars.aspthanks putts, but does that work if you are on a web page? ie, i want to get the <!-- m --><a class="postlink" href="http://www.blahblah.com/here.asp">http://www.blahblah.com/here.asp</a><!-- m --> for example?To get the URL complete with protocol (http://) and the domain name, I've built this little code snippet...

thisUrl = request.ServerVariables("URL")
thisPath = ""
while(instr(thisUrl,"/") > 0)
thisPath = thisPath & left(thisURL,instr(thisURL,"/"))
thisUrl = mid(thisUrl,instr(thisUrl,"/")+1)
wend

response.Write("<BR> URL : " & thisURL)
response.Write("<BR> Path : <!-- m --><a class="postlink" href="http://">http://</a><!-- m -->" & request.ServerVariables("SERVER_NAME") & thisPath)


In the end, thisURL is just the page name (index.asp) and thisPath will have the entire pathing below the server level (/mypages/start/index.asp)

If you really need dynamics on the protocol, there's a request.servervariable called HTTPS that will either have a value of "off" or "on"

To see all the servervariables for yourself....

<%
for each variable in request.ServerVariables()
response.Write(variable & " - " & request.ServerVariables(variable) & "<BR>" & vbCrLf)
next
%>putts you never cease to amaze me, thanksCheck out my personal ASP Code Bank. I have put tons of great ASP scripts for me to use and for guests. You can use and reprint any scripts you like w/out asking for permission.

URL: <!-- m --><a class="postlink" href="http://www.ex-designz.net/codemanager/default.asp">http://www.ex-designz.net/codemanager/default.asp</a><!-- m -->

Have fun!
Dexter
 
Back
Top