This project is read-only.

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.

Topics: Developer Forum, Localization Forum, Project Management Forum, User Forum
Mar 26, 2009 at 8:47 PM

I get this error when the application times out.

Server Error in '/' Application.

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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: 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.

Source Error:

[No relevant source lines]

Source File: c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\074cc749\53159149\App_Web_pdbiqqhx.2.cs    Line: 0

Stack Trace:

[HttpException (0x80004005): Unable to validate data.]
   System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +294
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +203

[ViewStateException: Invalid viewstate. 
	Client IP: 96.50.138.189
	Port: 52073
	User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7
	ViewState: /wEPDwUKMTU1NDc3NTc0NA9kFgJmD2QWAgIDD2QWAgIBEGRkFgQCAQ9kFgJmD2QWAgIHDzwrAA0CAA8WAh4LXyFEYXRhQm91bmRnZAwUKwAIBRswOjAsMDoxLDA6MiwwOjMsMDo0LDA6NSwwOjYUKwACFg4eBFRleHQFBEhvbWUeBVZhbHVlBQRIb21lHgtOYXZpZ2F0ZVVybAUOL2hvbWVwYWdlLmFzcHgeB0VuYWJsZWRnHgpTZWxlY3RhYmxlZx4IRGF0YVBhdGgFDi9ob21lcGFnZS5hc3B4HglEYXRhQm91bmRnZBQrAAIWDh8BBQhBYm91dCBVcx8CBQhBYm91dCBVcx8DBSIvYWJvdXRfd2VibWFzdGVyX25vdF9yZXF1aXJlZC5hc3B4HwRnHwVnHwYFIi9hYm91dF93ZWJtYXN0ZXJfbm90X3JlcXVpcmVkLmFzcHgfB2dkFCsAAhYOHwEFEFNlcnZpY2VzICYgUmF0ZXMfAgUQU2VydmljZXMgJiBSYXRlcx8DBRcvd2ViX3NpdGVfc2VydmljZXMuYXNweB8EZx8FZx8GBRcvd2ViX3NpdGVfc2VydmljZXMuYXNweB8HZ2QUKwACFg4fAQUOU3VwcG9ydCBDZW50ZXIfAgUOU3VwcG9ydCBDZW50ZXIfAwUUL3N1cHBvcnRfY2VudGVyLmFzcHgfBGcfBWcfBgUUL3N1cHBvcnRfY2VudGVyLmFzcHgfB2cUKwAFBQ8wOjAsMDoxLDA6MiwwOjMUKwACFhAfAQUERkFRcx8CBQRGQVFzHwMFCi9mYXFzLmFzcHgfBGcfBWcfBgUKL2ZhcXMuYXNweB8HZx4IU2VsZWN0Z...]

[HttpException (0x80004005): 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.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +267
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +282
   System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
   System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
   System.Web.UI.HiddenFieldPageStatePersister.Load() +198
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83
   System.Web.UI.Page.LoadAllState() +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.default_aspx.ProcessRequest(HttpContext context) in c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\074cc749\53159149\App_Web_pdbiqqhx.2.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Is there a way to :

Extend the time before it times out (some of my clients could use this)
Send information to the user upon the error (Something the regular person may understand when recieving the error.


I don't know about web farm or cluster

I am using a dedicated server running PLESK 8.3 for windows.

Shared IP with Dedicated Application Pools.


Mar 27, 2009 at 3:07 AM
You will want to have a <machineKey /> tag in your web.config with your own validationKey and decryptionKey.

This way your key will stay the same between IIS recycles and server reboots.

See this link for an easy way to generate the keys:   http://www.orcsweb.com/articles/aspnetmachinekey.aspx
Mar 27, 2009 at 4:01 PM
Ok that looks simple enough after visiting the mentioned web site.

One question though do I put the same machine key in all of the web config files i have running MWPSK (About 20) on the same machine or do i put a new one into each web sites config file?
Mar 30, 2009 at 2:05 AM
Either way works.  We've done both with no problems.  But I would suppose you would want to have separate keys for each. 
Sep 9, 2009 at 5:34 AM

My Viewstate problem persists even if I have followed all the solutions...

I'm developping the website with Visual Web Developper and when I launch it I get this Viewstate error message. I'm stuck in my work I need help.

Sep 10, 2009 at 6:48 AM

I had this issue a lot, so Finally I asked MochaHost what they could do to fix it, and we decided on the server farm I am on we needed to use SQL Server mode... like this  It did require them to install the ASPState database into my Database...

<sessionState mode="SQLServer"
sqlConnectionString="data source=db100.my-hosting-panel.com;
 Initial Catalog=MyDatabaseName;
 user id=db_userName;password=db_UserPassword"
cookieless="false"
regenerateExpiredSessionId="true"
allowCustomSqlDatabase="true"
timeout="800" />

Seems to me I had to create teh MachineKey some where along the line as well. although I don't seem to have one in my web.config file at this time...