In Page 1 on button click I redirect the page to page 2 with msgid, and in page 2 in page load I check whether the previous page is valid. So i check (this.Page.PreviousPage != null) but this is always null and the page gets redirected to page 1. I am doing this so that no one can change the msgid in the url. How can I solve this issues. thanks
Page1:
int msgid = Convert.ToInt32(Hidden_MsgID.Value);
string url = "Page2.aspx?MsgID=" + msgid;
Response.Redirect(url);
Page2:
if (this.Page.PreviousPage != null)
{
}
else
{
Response.Redirect("Page1.aspx");
}
instead of response.redirect I used server . transfer and it works
Server.Transfer(string.Format(“ResponseMetric.aspx?MsgID={0}”, msgid));
PreviousPagedoes only work withServer.Transferand/or cross-page-posting: http://msdn.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspxelements for your solution available here: work with
this.Request.UrlReferrer