I've got an MVC web app on azure, and a couple of hundred times a day, I get an The required anti-forgery cookie "__RequestVerificationToken" is not present.
in my unhandled exceptions logs.
I've set everything up correctly, my action method has the [ValidateAntiForgeryToken]
.
I can see from looking at the exception details that the token was present in the form, but the cookie was not present.
Anyone know what might cause this?
Here's the error in full.
System.Web.Mvc.HttpAntiForgeryException (0x80004005): The required anti-forgery cookie "__RequestVerificationToken" is not present.
at System.Web.Helpers.AntiXsrf.TokenValidator.ValidateTokens(HttpContextBase httpContext, IIdentity identity, AntiForgeryToken sessionToken, AntiForgeryToken fieldToken)
at System.Web.Helpers.AntiXsrf.AntiForgeryWorker.Validate(HttpContextBase httpContext)
at System.Web.Helpers.AntiForgery.Validate()
TYPE. __RequestVerificationToken. www.grpgroup.co.uk. This is an anti-forgery cookie set by web applications built using ASP.NET MVC technologies. It is designed to stop unauthorised posting of content to a website, known as Cross-Site Request Forgery.
Error: The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.
AntiForgeryToken() Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. AntiForgeryToken(String) Obsolete. Generates a hidden form field (anti-forgery token) that is validated when the form is submitted.
This can be caused by many issues. Things that can cause the issue:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With