Solved

Reading the full URL

Posted on 2013-12-08
4
237 Views
Last Modified: 2013-12-10
hello Experts,

In Classic ASP is there a way of reading the current URL, starting with http...?

Thanks
0
Comment
Question by:APD_Toronto
  • 2
4 Comments
 
LVL 9

Expert Comment

by:guswebb
Comment Utility
Use this code...

<%
MyURL ="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring
%>
0
 
LVL 9

Expert Comment

by:guswebb
Comment Utility
Or some slightly better code which checks for the presence of variables in the URL...

<%
MyQS = Request.Querystring
if MyQS <> "" then
MyQS = "?" & MyQS
else
MyQS = ""
end if
 
MyURL = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & MyQS
%>
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
Comment Utility
Hi,
to get the complete url
- protocol
- domain
- port
- path
- querystring
you can use this:

<%
if  Request.ServerVariables("SERVER_PORT_SECURE") = 1 then
  protocol = "https://"
else
  protocol = "http://"
end if
domName = Request.ServerVariables("SERVER_NAME") 
port = equest.ServerVariables("SERVER_PORT")
pagePath = Request.ServerVariables("URL")
qString = Request.Querystring 

yourUrl = protocol & domName 
If port <> 80 and port <> 443 Then
  yourUrl = yourUrl & ":" & port
End If
yourUrl = yourUrl & pagePath 

If qString <> "" Then
  yourUrl = yourUrl & "?" & qString
End if

%> 

Open in new window


HTH
Rainer
0
 

Author Closing Comment

by:APD_Toronto
Comment Utility
Great/useful liittle code!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now