Wednesday, December 15, 2010

How to fix Invalid viewstate and Validation of viewstate MAC failed in

There are couple of errors in related to viewstate
1. System.Web.HttpException: The client disconnected. —> System.Web.UI.ViewStateException: Invalid viewstate.
2. System.Web.HttpException: 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. —> System.Web.UI.ViewStateException: Invalid viewstate.

How to fix?
1. Check HttpResponse.IsClientConnected in page load event, if not, logoff user.
2. Check Application Pool Recycling IIS setting to avoid recycling is less likely to occur at peak periods
3. put machineKey section into your web.config (
Such as:

1. Intermittent Invalid Viewstate Error in ASP.NET Web pages;en-us;555353&sd=rss&spid=6351
2.ASP.NET state management: viewstate

Top 50 Programming Quotes of All Time


An introduction for hosting a MVC project into Cloud: