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

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 }))

......

你可能感兴趣的:(登录)