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));
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
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..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.