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

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

......

原文地址:https://www.cnblogs.com/wzh206/p/3153862.html