Solved

Reading the full URL

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Button function on table is in trouble 3 35
JQuery Autocomplete Tag AJAX (Need nice script) 11 57
Adjust an existing ASP Query 45 26
Designing forms 3 45
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…
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/…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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