I have my menu, and it has a dropdown
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Usuário</a>
<ul class="dropdown-menu" role="menu">
<li><a href="/">Meus dados</a></li>
<li><a href="#" id="LogOff">Sair</a></li>
</ul>
</li>
I tried to use the "Exit" in this way
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm"}))
{
@Html.AntiForgeryToken()
<ul class="nav navbar-nav">
<li><a href="javascript:document.getElementById('logoutForm').submit()">Sair</a></li>
</ul>
}
But it breaks with the menu by rendering a Form
Then I tried with Ajax
$("#LogOff").on("click", function (e) {
$.post('@Url.Content("~/Account/LogOff")');
});
So he sends the Post, but I have to give "Refresh" to login, ignoring the RedirectToAction
that is in action LogOff
and also does not accept ValidateAntiForgeryToken