How to check if a page is redirected from a previous page or not in asp.net

On page 1, click on the button to redirect the page to page 2 using msgid, and on page 2 in the page load I check whether the previous page is valid. Therefore, I check (this.Page.PreviousPage != null), but it is always null, and the page is redirected to page 1. I do this so that no one can change the msgid in the url. How can I solve these problems. thank

Page1:

  int msgid = Convert.ToInt32(Hidden_MsgID.Value);
    string url = "Page2.aspx?MsgID=" + msgid;
    Response.Redirect(url);      

Page 2:

if (this.Page.PreviousPage != null)
                {
                }
                else
                {
                    Response.Redirect("Page1.aspx");
                }

instead of response.redirect I used the server. transferring and running Server.Transfer (string.Format ("ResponseMetric.aspx? MsgID = {0}", msgid));

+5
source share
2 answers

PreviousPage Server.Transfer / : http://msdn.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspx

: this.Request.UrlReferrer

+10

, , , .

Session["PREVPAGE"] = "fooo.aspx";

.

+1

All Articles