Using Request.Referrer

W

Wayne Wengert

I want to restrict access to a specific ASP.NET page base on the calling
URL. I am trying the code below to get the calling URL but I get an error
"Object reference not set to an instance of an object". What is the correct
way to accomplish this?

******************* Code Snippet **************************
Dim strReferrer As String = Request.UrlReferrer.ToString

******************************************************
 
J

Joerg Jooss

Wayne Wengert said:
I want to restrict access to a specific ASP.NET page base on the calling
URL. I am trying the code below to get the calling URL but I get an error
"Object reference not set to an instance of an object". What is the
correct
way to accomplish this?

******************* Code Snippet **************************
Dim strReferrer As String = Request.UrlReferrer.ToString

******************************************************

Don't use Referrer for security features. This header can be changed by
proxies, is easily faked or not there at all if you invoke the URL directly.

Cheers,
 
W

Wayne Wengert

Joerg;

Thanks for the response. The planned use is not really a "security" issue -
we want to discourage bookmarking certain pages - we want users to enter the
site through the standard front end which includes announcements and such.
It is not a big deal if someone gets around the restriction but we figure
that this approach might discourage most casual users from bookmarking the
page.

Wayne
 
J

Jos

Wayne said:
Joerg;

Thanks for the response. The planned use is not really a "security"
issue - we want to discourage bookmarking certain pages - we want
users to enter the site through the standard front end which includes
announcements and such. It is not a big deal if someone gets around
the restriction but we figure that this approach might discourage
most casual users from bookmarking the page.

Then use this test:
If (Request.UrlReferrer Is Nothing) Then
' it's a bookmark
End If

Keep in mind though, that generally users don't like it if you take away
functionality.
It's rarely justified to do that.

It's better to include a user control with your announcements
as a header or footer.
 
W

Wayne Wengert

Thanks for that suggestion Jos.

Wayne

Jos said:
Then use this test:
If (Request.UrlReferrer Is Nothing) Then
' it's a bookmark
End If

Keep in mind though, that generally users don't like it if you take away
functionality.
It's rarely justified to do that.

It's better to include a user control with your announcements
as a header or footer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top