Reputation: 1552
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));
Upvotes: 7
Views: 26066
Reputation: 13835
Maybe you can use a session variable to check if the flow is followed as well.. Before your redirect you can set
Session["PREVPAGE"] = "fooo.aspx";
And retrieve it in the page load of the second page..
Upvotes: 1
Reputation:
PreviousPage
does only work with Server.Transfer
and/or cross-page-posting: http://msdn.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspx
elements for your solution available here: work with this.Request.UrlReferrer
Upvotes: 13