Avatar of rwhitlatch
rwhitlatch
 asked on

Validation of viewstate MAC failed

INFO:  C# Asp.Net 3.5 Web Application, Windows Server 2008, SQL Server 2008

I am getting a (seemly) random error message reported by my users when they login to my web application or even when they are in my application and navigate to a new page.  The exception occurs in some place I cannot seem to find and trap, so the user sees the exception page.  The error reported in various forms report this:

"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."

I have done research about this, and let me clear up these points.  The application is NOT on a server farm and it does NOT have "invalid" form actions.  

The view state settings are:

"<sessionState  mode="SQLServer"  sqlConnectionString="{connectionstring}"  cookieless="false" timeout="1200" />"

And does seem to work.  I have looked at the application pool, but it has been set to only recycle at midnight.  

The stack trace is:

System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +106
System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +242
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() +207
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +105
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49

Besides this random error, the application works great.

Thank you
ASP.NET

Avatar of undefined
Last Comment
rwhitlatch

8/22/2022 - Mon
pradyahuja

I have had this problem.
but my application was running on web farm.
However, go to
http://www.asprunner.com/forums/topic/3379-validation-of-viewstate-mac-failed/
and one of the solution is

try to add this string in <system.web> section of your web.config file :
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />

also have a look at

http://blogs.msdn.com/tess/archive/2009/04/14/validation-of-viewstate-mac-failed-after-installing-net-3-5-sp1.aspx
ASKER CERTIFIED SOLUTION
Kumaraswamy R

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rwhitlatch

ASKER
I will try those and report back.
rwhitlatch

ASKER
I went to http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx and used solution #3 and recieved reports from my users.  The amount of events went from 12 or so down to 2.  And those 2 I have traced down to improper URL's on my part.

Thank you.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes