我有一个ASP.NET MVC 4应用程序的问题。 我对部分代码进行了部分查看:
<li>@using (Html.BeginForm("LogOff", "Account", FormMethod.Post,
new { id = "logoutForm", style = "display: inline;" }))
{
@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log out</a>
}
</li>
点击&#34后,退出&#34;我重定向到:/帐户/登录?ReturnUrl =%f2Account%f2LogOff并采取行动:
//
// GET: /Account/Login
[AllowAnonymous]
public ActionResult Login()
{
ViewBag.Title = loginTitle;
return View();
}
但我想在行动中处理这个问题:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
Session["user"] = null;
return RedirectToAction("Index", "Index");
}
你能帮助我吗?
答案 0 :(得分:1)
看来您在注销时没有登录。