I have implimented the AnitforgeryToken with my asp.net MVC forms, and also added the attribute to my login procedure, however when the check failes i wish to redirect to my fraud action rather than an exception page. is this possible within the attribute ????
thanks
The ValidateAntiForgeryTokenAttribute will just throw HttpAntiForgeryException. You could use the HandleErrorAttribute to handle this scenario:
In case you do not want to put
[HandleError]
attribute on all actions that have[ValidateAntiForgeryToken]
, you may add a custom filter to your Global filters:in Global.asax under
Application_Start()
:and then:
AntiForgeryTokenFilter.cs: