The Template for a MVC 4.5.3 Account Controller has the following code:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut();
return RedirectToAction("Index", "Home");
}
Why does it need the first two attributes? I commented them out and simply called the function through a @Html.ActionLink() and it gets the job done. Is there any scenario in which this is required or would be beneficial to implement?
Edit: I understand the purpose of the ValidateAntiForgeryToken and the HttpPost attributes. Let me rephrase myself. How would I call this function with those attributes? Would it be through an API? I just wanted to create a simple button with an @Html.ActionLink() to LogOff. Is there a way I can approach this and keep the attributes?