【问题标题】:MVC 4 post automatically redirect to action that i dont wantMVC 4 帖子自动重定向到我不想要的操作
【发布时间】:2015-06-01 22:43:26
【问题描述】:

我遇到了 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>

点击“注销”后,我会重定向到:/Account/Login?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");
}

你能帮帮我吗?

【问题讨论】:

    标签: c# asp.net asp.net-mvc-4 action logoff


    【解决方案1】:

    您在注销期间似乎没有登录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-07
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多