Under the covers, the MVC AntiForgeryToken attribute uses the machine key for encryption. If you do not specify a machine key in the web.config file (see here ), it is automatically created for you by ASP.NET ( full description ).
If the ASP.NET application restarts (for example, iisreset), the AntiForgeryToken in the browser cookie will still be encrypted using the old machine key, so it crashes with the above error.
Therefore, you should always specify the machine key in your web.config when using MVC, for example
<configuration> <system.web> <machineKey validationKey="21F090935F6E49C2C797F69BBAAD8402ABD2EE0B667A8B44EA7DD4374267A75D7AD972A119482D15A4127461DB1DC347C1A63AE5F1CCFAACFF1B72A7F0A281B" decryptionKey="ABAA84D7EC4BB56D75D217CECFFB9628809BDB8BF91CFCD64568A145BE59719F" validation="SHA1" decryption="AES" /> ...
Dunc Oct 16 '09 at 10:07 2009-10-16 10:07
source share