go to ISQsolutions.com | Contact Us

Q10294 - PRB: Invalid Viewstate on ASP.NET pages.

You may receive the following error message from ASP.NET pages.

[HttpException (0x80004005): Authentication of viewstate failed. 1) If this is a cluster, edit configuration so all servers use the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. 2) Viewstate can only be posted back to the same page. 3) The viewstate for this page might be corrupted.]

Viewstate represents the state of the page when it was last processed on the server. The contents of the page are stored in a container and moved to and from the server on each request. By default, ASP.NET validates the contents of viewstate to ensure that it has not been tampered. If this validation test fails, an invalid viewstate exception is thrown. One of the issues that cause this test to fail is the recycling of the AppPool where the website lives.

IIS 6 will periodically recycle the application pool to maintain the health of the application pool. At the instance when the application pool is being recycled, browser requests may sometimes result in an invalid viewstate error.

The workaround is to use a specific key in the Web.config to prevent automatic key generation on each process start.  The key must be exactly 128 bits made up of random characters and inserted into the configuration file on each webserver experiencing the problem. An example follows.

<machineKey validationKey="EE94EFA0280BBF3A1FE0E8DC5FE9EB725C3CE9D0E59187EC91CF32B463241B4ED6A60E3152B158D30B5BD45D99F09D504D3F75AE860605A11806EDBEF88DAB3F"
decryptionKey="24996804B8C6C416BF7AE6BE7337AE590E404C00A91DB274" validation="SHA1" />

You can generate a pair of keys at the following page:



Related Articles
Q10295 - PRB: Intermittent ASP.NET sessions

Article Attachments
No Attachments Available.

Related External Links
ASP.NET Settings Schema.
<machineKey> Generator
Help us improve this article...
What did you think of this article?


Tell us why you rated the content this way. (optional)
Approved Comments...
No user comments available for this article.
Created on 9/2/2005 1:58:00 PM.
Last Modified on 7/1/2011 5:44:00 AM.
Last Modified by ISQ Solutions Inc.
Article has been viewed 15347 times.
Rated 7 out of 10 based on 7 votes.
Print Article