How to Find the Current URL in ASP
1 Comment Published by Steven 4 years, 10 months ago in ASP and ASP BasicsThe full URL to a page comes in three parts: The domain name, the path to the file then the filename, and the QueryString. For example, take the URL http://www.example.com/example/page.asp?name=Bob. The three parts of this are:
1. The domain name: www.example.com
2. The path to the page: /example/page.asp
3. The QueryString: name=Bob
So how do you find it all out with your own scripts?
Well the following code should do it:
ASP:
-
<%@language="VBScript"%>
-
<%
-
Dim strDomain, strPath, strQueryString, strURL
-
‘ find out the domain:
-
strDomain = Request.ServerVariables("HTTP_HOST")
-
‘ find out the path to the current file:
-
strPath = Request.ServerVariables("URL")
-
‘ find out the QueryString:
-
strQueryString = Request.ServerVariables("QUERY_STRING")
-
‘ put it all together:
-
strURL = "http://" & strDomain & strPath & "?" & strQueryString
-
Response.Write "The current URL is: " & strURL
-
%>
One Response to “How to Find the Current URL in ASP”
Leave a Reply
You must log in to post a comment.
Search
Categories
- ASP (3)
- ASP Basics (3)
- Blogs (2)
- C# (1)
- Firefox (1)
- Flash (1)
- Google (6)
- Hacks (3)
- Java (1)
- PHP (12)
- Basics (8)
- Files (1)
- Image Handling (3)
- Ruby (1)
- Tips (10)
- Web Hosting (3)
- Web Hosting Articles (1)
- Web Hosting News (2)
- Windows (6)
- Wordpress (2)
Related Entries
- No related posts.
How do I capure the IP address and store it only? I am building a web-based survey and I want to pass the data into the database.
Thanks,
donna