Fix for Dot Net Error Validation of viewstate MAC failed

View state issues with the error “Validation of viewstate MAC failed”. I ran across this error while building a report in c# web forms. The error first started when a viewer refreshed the screen after a long period of no use. Evidently this is a common issue with dotNet apps located on a server instance that also houses several other applications within the same instance (same issues as those experienced with a Web Farm). One fix I found to get around this issue is to switch from auto-generated keys to defining static complex keys.

The following is generated from a completely random key generator that I have developed. Refresh the screen to generate a new set of keys.

validationKey is SHA1 and 128 bits
decryptionKey is AES and 64 bits

Add this to your web.config

Adapted from this MSDN article on MachineKey Configuration.

Bookmark the permalink.