English 中文(简体)
如何检查页次从前页转至正文。
原标题:How to check is page is redirected from previous page or not in asp.net
  • 时间:2012-01-12 11:47:07
  •  标签:
  • c#
  • asp.net

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

页: 1

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

页: 1

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

http://www.dotnetcurry.com/ShowArticle.aspx?ID=89“rel=“noretinger”>here:与this合作。 请求。 UrlReferer

问题回答

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";

并检索第二页的页数。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签