Welcome to my ASP Code Website

Referring URL with HTTP_REFERRER

When you are coding ASP pages, you often want to know where the user came from. Using HTTP_REFERRER lets you code your pages based on what path the user followed.

Simply put, add this code to your ASP page -

RefURL = Request.ServerVariables("HTTP_REFERRER")

Now you have the full value of the previous URL in the RefURL variable. Users can of course block this with their browser settings if they want to, but not all users are quite that paranoid about their security settings.

There are many reasons that knowing the referring page can be useful.

* You can make sure that a thank you page thanks the person based on what product they bought.

* You can ensure that a paypal return page only activates fully for someone that really DID just come from the PayPal website.

* If someone tries to 'leap' to a end-stage page directly, you an always response.redirect the user back to the starting point.

Make sure you do account for users that have blocked this feature, so they at least see a page explaining that they need to change their security settings.

ASP Utility Code