473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

problem with UrlReferrer on first instance of home page

Hi

I have this declaration on most of my pages for the UrlReferrer.

String referrer=Request.UrlReferrer.ToString();
This works fine apart from when the user first visits the site on the home
page, which results in the following error

"Object reference not set to an instance of an object"
if i take the above line out , navigate to another page, put the line back
in to home page and navigate back to home page it works fine. So I am
guessing that at the start of the session UrlReferrer doesn't exist until
after the first page navigation. Any ideas how I can get round this?

tia.

Nov 18 '05 #1
1 2023
the referrer is the page that sent you to this page, so naturally, on the
first page, you don't have a referrer

to get around it,

dim Referrer as string

if Request.URLReferrer is Nothing then
Referrer = ""
else
Referrer = Request.URLReferrer.ToString()
end if

or the equivalent in C#
"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*******************************@140.99.99.1 30...
Hi

I have this declaration on most of my pages for the UrlReferrer.

String referrer=Request.UrlReferrer.ToString();
This works fine apart from when the user first visits the site on the home
page, which results in the following error

"Object reference not set to an instance of an object"
if i take the above line out , navigate to another page, put the line back
in to home page and navigate back to home page it works fine. So I am
guessing that at the start of the session UrlReferrer doesn't exist until
after the first page navigation. Any ideas how I can get round this?

tia.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ivan Demkovitch | last post by:
Hi! Here is what I'm doing: I have Login.aspx with code to do forms authentification and I have this line at the end: Response.Redirect(Request.UrlReferrer.ToString()); I have other...
1
by: John | last post by:
Hi, all - On Page1.aspx I have a button control that, when clicked, Response.Redirect("Page3.aspx"). On Page2.aspx I have a hyperlink to Page3.aspx. On Page3.aspx, I want to know which page...
12
by: Britney | last post by:
Hi guys, in my default.aspx file, I have following code. when I go to browser, I enter values in both textboxs, then I hit submit Button, however, it didn't go to page2.aspx. instead, it was...
2
by: ad | last post by:
I have tree web page A.ASPX, B.ASPX and CheckPW.aspx There is a button in A.ASPX, the click of that button is redirect to B.ASPX .. I write a Page_Load event in b.aspx, if the Session is null...
0
by: Tony | last post by:
I'm trying to capture referrer information. the requests are the first lines of code in the page load sub. Request.UrlReferrer.tostring 'produces the name on of my site not the referrer...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
2
by: Charlie J | last post by:
I have a real stumper. I added a server side table to a home page that has two other server side tables on it that have been working great. In Visual Studio everything works great. When I put...
2
by: deepak.bhardwaj | last post by:
Hi, I have implemented the IHttpHandler interface for generating images and writing them to response stream in binary format. I use an IHttpHandlerFactory to instantiate that handler. A .aspx...
0
by: superman | last post by:
Hi, I have implemented the IHttpHandler interface for generating images and writing them to response stream in binary format. I use an IHttpHandlerFactory to instantiate that handler. A .aspx...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.