To read the article online, visit

Two Ways To Protect Your ASP Page
By JoM-co Vieira

There may be a time when you have certian .ASP pages that you only want people to be able to access when going through your site. You don't want other websites to link directly to these pages (for example, you may want a user to have filled out a lengthy form before arriving at a certain page). It's not difficult to protect your ASP pages this way. We will use the Request.ServerVariables collection to perform this task. (To see information on how to make sure your images are only accessed by pages on your site, be sure to read Bart Silverstein's article, Protecting Your Images!)

At the top of the .ASP page that you want "protected" put this code:

if left(Request.ServerVariables("HTTP_REFERER"),24)  <> "" and _
	Request.ServerVariables("HTTP_REFERER") <> "" then

	'We used Request.ServerVariables to get the domain name
	'of the referring web page.

	'If the domain name doesn't equal my domain name, then
	'I want to send the user to some other site
	Response.Redirect ""
end if

This next method uses the IP number, which can be useful when you do not yet have the domain but still want to test it online.

At the top of your ASP page put this code:

if Request.ServerVariables("REMOTE_HOST") <> "" and _
	Request.ServerVariables("REMOTE_HOST") <> "" then

	'Send them away, if you like
	Response.Redirect ""
end if

Happy Programming!

Article Information
Article Title: Two Ways To Protect Your ASP Page
Article Author: Joao Vieira
Published Date: Sunday, May 30, 1999
Article URL:

Copyright 2019 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers