ASP.NET “Validation of viewstate MAC failed” error

I came across this error:

“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.”

This happen due to the application pool’s “IdleTimeout” set to a lower value compare to your session timeout value. Let say your session timeout set to 20 mins but your app pool idle time out set to 10 mins.  After 10 mins, app pool sshutdown the worker process. If you do not handle the session expire well, you may get this error. You have to either hanlde via the code or just set the Idle Timeout setting to a greater value compare to your session timeout value.

Posted in .Net.

5 Responses to “ASP.NET “Validation of viewstate MAC failed” error”

  1. Hardik Says:

    What is the Solution of Following Error

    “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.”

  2. ¥ong¥s Says:

    Hi Hardik,

    You can try to change the Idle Timeout setting in your application IIS app pool. If your application session timeout setting is set 20 mins, you have to change to >= 20 mins. By default this setting is set to 5 mins which will cause the error.

  3. himanshu Says:

    the timeout the not the problem in my case, as i m still facing the same error, after every two three entry in the database, whats the issue some says time out, some say too many click simultaneoulsy, etc.

    Can you please suggest me some more hit and trial so that the erro wont come.

  4. ¥ong¥s Says:

    Hi himanshu,
    I am not sure what is the environment in your case. If it is in Web Farm or Cluster Environment, make sure you use
    Out-of-process Mode in your session state. More info on http://msdn2.microsoft.com/en-us/library/ms972429.aspx.

    Using wrong session state will cause time out error after few postbacks. For my case, i change the session state and the timeout setting as above. It solve my problem. Good Luck!

  5. ASP.NET “Validation of viewstate MAC failed” error « yyTech Blog on .Net, SQL, SharePoint, Collaboration and tech tips. Says:

    [...] Read the rest of this entry (moved to http://www.bronios.com) » Posted in .Net. [...]

Leave a Reply