tags:

views:

255

answers:

2

I am getting the following error whenever I click on a postbacking control

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.

I am not using a Web Farm or cluster server. I have even tried setting the page property EnableViewStateMac to false but it changes the error message stating

The state information is invalid for 
this page and might be corrupted.

What could possibly be wrong?

+3  A: 

There is an article about this here: http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx .

The basic problem is that Your page hasn't completed loading before You perform the postback.

A few different solutions are in the article listed above: 1. Set enableEventValidation to false and viewStateEncryptionMode to Never 2. Mark the form as disabled and then enable it in script once the load is complete. 3. override the Render Event of the page to place the hidden fields for Encrypted Viewstate and Event validation on the top of the form.

But the main problem is that the page load slow, which should be fixed (if possible ASAP). It can also be good to apply solution 2 above as well as there will always be trigger happy users that will click faster that the page loads no matter how fast it loads :-).

/Andreas

A: 

I have encountered the same problem with a custom build ASP.NET control which was dynamically reloaded and rebuild on every POST / GET request. Thus the page sending the POST request was not the same as the one recieving the response. If you use any custom or databound controls look closly how they behave on a POST back.

Drejc