Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore, Dream. Discover.
I am getting the below error in my ASP.NET 4.0 web application:
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.
I started getting this error when I added the below tag in web.config to encrypt the viewstate:
I looked for lot of solutions on aspnet forums and Internet but nothing worked. If I change the viewStateEncryptionMode to "Auto" or "Never", then the page loads fine. But that would make my application insecure and security is my prime objective.
FYI:My application is deployed on a Windows 2008 R2 server and not on a webfarm.
Any solution to solve this issue?
First, just to check the simplest solution, you aren't posting back "old" pages are you? By this I mean getting the page when the viewstateEncryptionMode is off/auto, switching the mode to on then posting back. This wide cause the error, but is unlikely Tokyo are doing this.
This problem is ringing a bell, but I can't place my finger on it. You might be suffering from this http://blogs.msdn.com/b/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx (On my mobile so can't make clickety),though this was fixed IIRC.