0
votes

I am getting the follwing error,please tell me why this error is coming

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.

2
Where do you get this error?Boldewyn
How about posting a descriptive title + tags? And the question sucks too.Ben Everard
Multiple duplicates - searching on Validation of viewstate MAC failed gives over 10 pages of resultsblowdart

2 Answers

1
votes

this can happen when you post a form which in the meantime has been updated on the server, or the app has been recycled in IIS.

0
votes

By default Viewstate is generated based on the MAC address of the machine that the web server is running on - this can cause problems when load balancing web traffic across a web farm or cluster as there is a chance that a pages post back request might get processed by a different machine from the one that originally generated the viewstate token, which will cause the exception that you see above.

If your running a web farm / cluster then the answer is the <machineKey> configuration element - if you set this to the same algorithm / key for each of the machines then viewstate is generated based on this key instead of the MAC address of the machine, preventing the above problems.

This blog article probably explains it better than I just did.