We help IT Professionals succeed at work.

ViewState validation error ASP.NET

royend asked
Dear experts,
Until yesterday everything was working perfect for my website. Then, my users started reporting about invalid ViewStates:
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 googled and found a method which would set the ViewState constant, and thus securing that the ViewState would be correct for all users. This, however, made the ViewState not unique for my users, as it seems they share the same session-data. Sharing session-data resulted in frequently "Object does not exist" when a user tried to load some session-variable.

I guess the only correct thing would be to go back and try to fix the first error: The error of ViewState validation for my users.

Does any of you have any solution to this problem?
Or a hint about what may be wrong?

Looking forward to your help :)
Watch Question

Did you try adding the below line to your web.config?
<pages enableEventValidation="false" viewStateEncryptionMode="Never">


Thanks for your suggestion. I tried it, but it gave me the same session-error as before:
Object reference not set to an instance of an object.

I should also add that I have tried turning the ViewState off, by setting

But, as I seem to be dependent on viewstate (e.g. when using CascadingDropDownList and a WebService (.asmx)), this resulted in several functions not working at all (e.g. the DropDownList being empty).
So If i understand correctly, the line in my prev post actually is not causing the view state error but still it does not really solve your problem. Sounds right?


Yes. Your line does not cause any view state error, but I get a session error instead. Therefore my problem is the same.
Could you explain a bit why you are getting the session error and where you are storing the session? Is it a webfarm scenario?


I appreciate your feedback :)

It is not a webfarm scenario.

The session is stored in order to save a temporary order (in the making), as the user needs to alter the order live (adding, removing, changing products in a shop cart).

But isn't it better to try to solve the original ViewState error?
The session error only occurs if I set the ViewState validation- and decryptionkey as a constant, or set the viewStateEncryptionMode=false.

Also, remember that everything worked perfect (for more than a year), with the session-handling of the shop cart...
This is the issue with the .net framework

To get the fix you will have to contact Microsoft at 800 936-5800 (select option 3) to open a case and request Fix number KB 361949

For details check


Thanks for your tips AmanBhullar.
An alternative to the fix (according to the links), is to upgrade the solution to ASP.NET 3.5. I have upgraded my solution, but I still get the same ViewState-error.

I hope you will continue to provide suggestions on how to solve this :)
Top Expert 2010
Have a look


NB : Make sure you dont have two form tags in the master page if you are using master page


Thanks for your comment!
I am afraid adding a postbackurl to every clickable button in my solution is not an option. I  noticed from your link that users also reported problems implementing this for dropdownlists which has an autopostback, and this would also be a problem for my solution.

It surprises me that a website can go from fully functional to not working, withoug editing the code. It has been more than a week since I did some minor changes, and the last major changes happened months ago. Why?

Please keep posting new suggestions :)


None of the suggestions solved my problem (it was due to a server error limiting the  number of parallell sessions). But, the proposed solutions will work as a guide for others having ViewState-error.

Thanks for your solutions :)