I have ValidateAntiForgeryToken
attribute applied at class level. As shown in the below code.
[ValidateAntiForgeryToken, Authorize(Roles = "SuperUser")]
public class ManageController : BaseController
{
...
}
This class has several methods which accepts POST
data and couple of methods which are exposed for GET
operation. I would like to disable ValidateAntiForgeryToken
for GET
method without changing class level attribute. I know that I can do this by changing all the POST
methods and applying ValidateAntiForgeryToken
just to them. But I am hoping their is an easy way.
Just like the way Authorize
attribute works along with AllowAnonymous
where you can apply Authorize
attribute at class level but then can change it method level by applying AllowAnonymous
.
[Authorize]
public class AccountController : BaseController
{
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
return View();
}
}