How to Find the Current URL in ASP
Published 2 years, 9 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:
-
<%@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
-
%>
If you have a website, consider joining the Money4Banners advertising network. They will pay you £10 + £5 each month for displaying a small advert on three of your pages, regardless of traffic. American webmasters are welcome, and since £10 == $20, you make more!
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)
- deals (1)
- Firefox (1)
- Flash (1)
- Google (6)
- Hacks (4)
- Java (1)
- PHP (12)
- Basics (8)
- Files (1)
- Image Handling (3)
- Puzzles (1)
- Ruby (1)
- Tips (10)
- Web Hosting (3)
- Web Hosting Articles (1)
- Web Hosting News (2)
- Windows (6)
- Wordpress (2)
Related Entries
- How to Find the Current URL with PHP
- Find a visitor's IP Address in ASP
- How to use the QueryString in ASP
- PHP
- How to Access a Page in Google's Cache
- Hacking the translation plugin for nicer URLs
- Web Hosting Terminology
- Save Embedded Media and Other Files in Firefox
- Generate a Month Calendar In PHP
- Use Google to define words
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