Reputation: 11
I have a problem with ASP.NET MVC 4 application. I have a partial view with fallowing code:
<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>
And after i click "Log out" im redirected to: /Account/Login?ReturnUrl=%f2Account%f2LogOff and going to action:
//
// GET: /Account/Login
[AllowAnonymous]
public ActionResult Login()
{
ViewBag.Title = loginTitle;
return View();
}
But i want to handle this in action:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
Session["user"] = null;
return RedirectToAction("Index", "Index");
}
Can you help me?
Upvotes: 0
Views: 290