In the Visual Studio OOB forms based authentication example for MVC, a postback is used when the user logs out,
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) {
@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}
Is there a reason why this isn't regular GET since no data is being sent back to the server?
A logout operation is not idempotent so it's good to use POST.
GET should only be used to retrieve resources. A logout is an operation and doesn't return a specific resource.
GET requests can also be cached, remain in the browser history and can be bookmarked. Some useless functionalities for a logout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With