Solved

Reading the full URL

Posted on 2013-12-08
4
246 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 500 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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