How to catch HttpAntiForgeryException in ASP.NET MVC

Posted by megalonychidae on Stack Overflow See other posts from Stack Overflow or by megalonychidae
Published on 2009-07-20T15:55:24Z Indexed on 2010/03/21 17:01 UTC
Read the original article Hit count: 334

Filed under:

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?

© Stack Overflow or respective owner

Related posts about asp.net-mvc