Validation of viewstate MAC failed. If this application is hosted by a Web Farm

For More Videos Visit Our YouTube Channel


Validation of Viewstate MAC Failed, If this application is hosted by a Web Farm or cluster, ensure that machineKey configuration specifies the same validationKey and validation algorithm, AutoGenerate cannot be used in a cluster.

Two things to consider here.

1. ViewState

2. Message Authentication Code (MAC)



1. What is ViewState

When postback happens on webpages, the information of the webpage will be stored on the ViewState. After postback, the page controls would get the data from the ViewState.

2. What is Message Authentication Code (MAC)

When doing the page redirection or postback, there is a possibility that the data in the ViewState can be tampered. Can be called as HACKED ...!!!!!! ... In oreder to protect this tampering, the Viewstate data is protected by Message Authentication Code (MAC). This Error mainly occurs When the MAC validation for the Viewstate fails. When there is not provided any machine key on the web.config of each IIS application then Asp.Net automatically generate cryptographic key for each application and stores the key in the HKCU registry. When mismatch happens between the applications on the auto generated key, this error happens.



On the web.config of your asp.net application, add the following code for machine key.

Validation of Viewstate MAC Failed, If this application is hosted by a Web Farm or cluster, ensure that machineKey configuration specifies the same validationKey and validation algorithm, AutoGenerate cannot be used in a cluster.

For Creating the machine Key, Please follow link. How To Generate Machine Key On IIS

For Video of Generating Machine Key : Youtube - How To Generate Machine Key On IIS

This would definitely resolve the issue.