how can I get tthe referring page?

B

buran

Dear ASP.NET Programmers,

I want to store the referring page of an .aspx page so that I can redirect
the user back to the referring page if needed. I am using the following code
snippet but receiving Object reference not set to an instance of an object
error. The code is as follows:

If Not Page.IsPostBack Then
Viewstate("ReferrerURL") = Request.UrlReferrer.ToString()
LoadData()
End If

Why am I receiving this error? Thanks in advance...

Buran
 
M

Martin Dechev

Hi, Buran,

You should not rely on this parameter as it might be incorrect in a variety
of cases.

You can send the referer in the query string from the refering page. You
will not need to store it in the ViewState as it will be preserved between
the postbacks anyway.

Greetings
Martin
 
B

buran

Thank you Martin! :)

Buran

Martin Dechev said:
Hi, Buran,

You should not rely on this parameter as it might be incorrect in a variety
of cases.

You can send the referer in the query string from the refering page. You
will not need to store it in the ViewState as it will be preserved between
the postbacks anyway.

Greetings
Martin
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top