Validation of Viewstate MAC failed error

Hi Friends,

I came across with  the following error in many occasions in windows hosting environment.
~~~~
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
~~~~

Sometime, some hosts will disable the auto-generation of Machine keys. So the following code in your web.config becomes useless and will show errors:

<machineKey validationKey="AutoGenerate,IsolateApps"  
            decryptionKey="AutoGenerate,IsolateApps" 
            validation="SHA1" decryption="Auto" />

Please note that you will get error with above code only if your server has the Auto-generation of Machine key disabled from IIS configuration.

In such cases for some applications which needs the Machine keys to be generated to validate the session states, will face issues. The issue can be fixed by adding the following code in your web.config file.  Please note that you need to include them within system.web directives.

<machineKey validationKey="2EEA416CEFC6D6BE856ED57B97FB9CA7DFACE17C073125949A1D682C80A44BB2AD887DDDC13DBFB0954F1000FEE5757E99693F222F8E28CAA2E6DAB8C4F99E0C"
decryptionKey="877478B2F33A74226ABEF55FDCC1A76E43F1BBEA6241A592" 
validation="SHA1" />

I hope the above solution will help you. Thanks again for your time friends.

Have a Great Day !!! 🙂 😉

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s