Solved

Reading the full URL

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.net VB.net gather value of text box text change 4 54
Classic ASP application Will support SQL 2014 5 93
ASP CDO - Limiting Connections 3 59
Help with query 3 31
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

792 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