A solution for error "Validation of viewstate MAC failed"

Posted: July 30, 2008 in ASP.NET
Tags: ,

This is not the first time I have faced this error. I have faced this issue many times in my development career. However, today I got this error on one of my developed live site and hence I have decided to make a post.

The full message of this error reads “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.

This is a common error which can be found on IE 6 or lower version browsers, when any web page gets idle for more than 20 minutes or so.

To resolve this issue, only you need to do is to set the page directive in your web.config file with following attributes.

<pages enableEventValidation=”false” validateRequest=”false” viewStateEncryptionMode=”Never” enableViewStateMac=”false”>

  1. mista bigg says:

    can’t do that as some pages do use viewstate …. just not the one giving this error.

  2. hspinfo says:

    Hi Mista,

    You can apply the “Page” directive to individual page where you are sure about the page which generates error, or the page where you have not used viewstate…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s