The sample Identity project uses this to log out:
@if (Request.IsAuthenticated) {
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" })) {
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right">
<li>@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
</ul>
}
}
And the AccountController.LogOff()
action method has a [HttpPost]
.
The only reason I can think of to use a POST rather than a GET, is the [ValidateAntiForgeryToken]
. And I don't see the purpose to that, all we're doing is logging out.
Surely this is overkill? Why not use a regular GET link?