登录以后,能够返回到登录前画面

1. Controller

[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)

2. View

@model MvcApplication2.Models.LogOnModel

@{

    ViewBag.Title = "Log On";

    string retUrl = "";

    if (ViewContext.HttpContext.Request.UrlReferrer != null)

    {

      retUrl =
        ViewContext.HttpContext.Request.UrlReferrer.PathAndQuery;

    } 

}

......

@using (Html.BeginForm("Logon", "Account",
  new { model = this.Model, returnUrl = retUrl }))

......

posted on 2013-06-24 23:03  Chopper  阅读(262)  评论(0编辑  收藏  举报