Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 20th, 2003, 05:07 PM
Authorized User
 
Join Date: Aug 2003
Location: Austin, TX, USA.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTTP_REFERER Tester Sometimes Redirects OK Visitor

I use the following ASP code in pages of my site to redirect visitors to the main page of the site if they did not come from a link:

If(Request.ServerVariables("HTTP_REFERER")="") Then
Response.Redirect "http://www.ab-cpe.com"
End If

The problem is that sometimes legitimate visitors to the pages (e.g. from a link) get redirected to the main page.

I don't understand why. Any help would be greatly appreciated!
__________________
Mark J. Weisberger
  #2 (permalink)  
Old August 21st, 2003, 03:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

The referrer is in the HTTP header and it is the user's browser that decides when/if to send it - you have no control over this.
  #3 (permalink)  
Old August 21st, 2003, 08:01 AM
Authorized User
 
Join Date: Aug 2003
Location: Austin, TX, USA.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help. Originally posted by pgtips
 The referrer is in the HTTP header and it is the user's browser that decides when/if to send it - you have no control over this.
[/quote]

Mark J. Weisberger
  #4 (permalink)  
Old August 21st, 2003, 08:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

For info on when it works and when it doesn't, I just stumbled across this article entitled "What is wrong with Request.ServerVariables("HTTP_REFERER")?"
http://www.aspfaq.com/show.asp?id=2169
  #5 (permalink)  
Old August 21st, 2003, 11:41 PM
Authorized User
 
Join Date: Aug 2003
Location: Austin, TX, USA.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for link. I agree now with the author when he/she says: "this variable cannot be relied upon for many situations." It's weird how HTTP_REFERER worked okay in most cases, but not in other cases... WITH THE SAME EXACT BROWSER (Internet Explorer 6.0). Maybe there's a setting somewhere in IE to allow or not allow referring URL's names to remain accessible by destination pages. Nonetheless, I'll change to session variables for security now. They're a little more complicated, but probably better in the long run. Thanks again for your help.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error while testing the class tester curiaquita Java Basics 5 February 13th, 2009 02:07 AM
Has anyone got a visitor counter ? gb012993 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 February 5th, 2008 04:01 AM
visitor duration per page esemerda Pro PHP 2 September 8th, 2005 01:38 PM
Redirects skicrud Beginning PHP 1 October 10th, 2003 12:50 PM
Querystrings and Redirects hcweb Classic ASP Basics 3 July 30th, 2003 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.