How to catch HttpAntiForgeryException in ASP.NET MVC
- by megalonychidae
I'm using the AntiForgeryToken in my ASP.NET MVC forms. If I deactivate cookies in my browser and send the from, I'd get following error message:
A required anti-forgery token was not supplied or was invalid.
How can I prevent this message from showing? I would prefer redirecting the user to another page.
I've activated customErrors and included this HandleError in my controller:
[HandleError(ExceptionType=typeof(HttpAntiForgeryException), View="Index")]
public class MyController : Controller
{
...
}
The HandleError is ignored.
Has anyone got a solution?