Using Request.ServerVariables

Many sites place a link to a feedback form on the bottom of every page. It is useful to track which page the user was viewing when that link was clicked.

I normally hand code a unique query string for each link and use that value as the email's subject. However, it is sometimes useful to see the full url - then, in the email client, you can just click on the link to see the page. It is also useful for tracking people who request your feedback page without actually clicking on one of your links - think spammers.

This page discusses an automatic method of obtaining using the Microsoft ASP Request.ServerVariables.

ASP Request Object | Example ASP Program | Example Output |


ASP Request Object

Microsoft provides several ASP Built-in Objects - this page is concerned with the Request object.

Any time an HTTP request is made, the data that the server receives is made availble to your program via the Request object. I have found the following 3 collections to be useful

However, be aware that this data can be faked by malicious users. You should not trust any of it for email addresses, query strings, and the like.


Example ASP Program

Because these are collections (a type of array), you can write programs to see what the collection contains. Microsoft provides following code as an example.

To use it, add basic html tags and save it to your web server (Windows / IIS only) as an asp file. I have NOT provided a link to my copy of this file because it exposes my email address ... and one of my goals is to hide that from spammers.


Example Output

This is a partial output of the program above - there is a lot more. Of particular note, HTTP_REFERER does not exist if you type the url in the address bar ... it only exists when a link is clicked (or if some hacker is playing games - use all data with caution).


Author: Robert Clemenzi
URL: http:// mc-computing.com / ISPs / Request_ServerVariables.html