ASP.NET Viewstate error - Validation of viewstate MAC failed

Last week I was working with on a case where they were getting this error message

HttpException (0x80004005): 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

Typically this occurrs if the application is on a webfarm and autogenerate is used as the validation key.  This is because if you request a page and click a button for example, the postback may go to another server in the web farm and if the validation keys don't match, asp.net will consider the viewstate as invalid.

However, in this case, they were not on a web farm so none of this applied.  

Viewstate and viewstate validation use a couple of hidden form fields like __VIEWSTATE and __EVENTVALIDATION.  If the page renders so slowly that the __EVENTVALIDATION field has not rendered by the time someone clicks the button or control that causes the postback, ASP.NET will also believe that the viewstate is invalid and report this.  

I had gotten this far and in my case I also knew that the viewstate used was very large which of course causes the page to take longer to render so I asked them to reduce the viewstate as much as possible and review the page to determine why it took so long to render.  

I still recommend this, but this weekend I also read this article from my colleague Tom that gives more details along with some solutions for the issue and I thought I'd share it with you in case you don't subscribe to his blog.    

 

Later,

Tess