?
Solved

Reading the full URL

Posted on 2013-12-08
4
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:guswebb
ID: 39704697
Use this code...

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

Expert Comment

by:guswebb
ID: 39704706
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 2000 total points
ID: 39704987
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
ID: 39709857
Great/useful liittle code!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

719 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