0

I have a link on page 1 if clicked take u to page 2

and page 2 if u click okay it should take u back to page

but when I use this on page 2 to:

ViewState["back"] = Request.UrlReferrer;

it returns null,

how do I fix this

on page 1:

link_Click(Obj sender, EventArgs e)
{
Response.Redirect("page2.aspx?ID" + row.cells[10].text)
}

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Ramesh S
0

You need to to get the Request.UrlReferrer if(!IsPostBack) in the Page_Load event and store it in the viewstate if your page perform postbacks.

Sometimes the Request.UrlReferrer is null if you are using AJAX to call Response.Redirect.

The UrlReferrer is based on the value of HTTP_REFERER header that a browser should send. Sometimes internet anti virus programs such as Norton's Internet Security will strip the header. Therefore the Request.UrlReferrer will be empty.

Instead of believing the Request.UrlReferrer, send the current page name as query string to the other page. In the target page, store the value of the query string in ViewState.

Refer these links.
http://stackoverflow.com/questions/149130/request-urlreferrer-null
http://stackoverflow.com/questions/1258324/should-request-urlreferrer-be-null-in-pageload-when-the-page-came-from-another-s
http://forums.asp.net/t/1101617.aspx

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.