how can I get tthe referring page?

  • Thread starter Thread starter buran
  • Start date Start date
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
 
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
 
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
 
Back
Top