ASP.NET Error Validation of viewstate MAC failed

Validation-of-viewstate-MAC-failedIn some environments the following error may occur for ASP.NET:
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.

There are a few reasons of this error and you can solve it by adding MachineKey to the Web.config file of your application. To do this follow the steps:

1) Open IIS manager.
2) If you need to generate and save the MachineKey for all your applications select the server name in the left pane, in that case you will be modifying the root web.config file (which is placed in the .NET framework folder). If your intention is to create MachineKey for a specific web site/application then select the web site / application from the left pane. In that case you will be modifying the web.config file of your application.
3) Double click the Machine Key icon in ASP.NET settings in the middle pane:

4) MachineKey section will be read from your configuration file and be shown in the UI. If you did not configure a specific MachineKey and it is generated automatically you will see the following options:

5) Now you can click Generate Keys on the right pane to generate random MachineKeys. When you click Apply, all settings will be saved in the web.config file.

Now the error should vanish.

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com