I am working on a web store app using C# 3.5 web forms and MS SQL Server 2008. The solution runs fine on VS2010, using the built-in web server. Then I upload the project to a testing sub-domain and the home page loads; as soon as I click on a menu link, I get this: Validation of viewstate MAC failed. This didn’t occur early in my project and I haven’t built anything weird or bizarre, normal CRUD stuff with a session-variable menu structure concept. I am stumped and now I seek help from the stackoverflow genius pool. Any suggestions?
I am pasting the stack trace info from the error page:
[ViewStateException: Invalid viewstate.
Client IP: omitted by user
Port: 53604
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; Tablet PC 2.0; OfficeLiveConnector.1.5; OfficeLivePatch.1.3)
ViewState: /wEPDwULLTEwMDUyNjYzMjhkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYMBRJjdGwwMCRpbWdCX05hcGtpbnMFFmN0bDAwJGltZ0JfVGFibGVjbG90aHMFEmN0bDAwJGltZ0JfUnVubmVycwUSY3RsMDAkaW1nQl9QaWxsb3dzBRFjdGwwMCRpbWdCX0Fwcm9ucwUQY3RsMDAkaW1nQl9XcmFwcwURY3RsMDAkaW1nQl9RdWlsdHMFEmN0bDAwJGltZ0JfSG9saWRheQUUY3RsMDAkaW1nQl9PdXRlcndlYXIFEmN0bDAwJGltZ0JfSnVkYWljYQUTY3RsMDAkaW1nQl9LaWRTdHVmZgUVY3RsMDAkaW1nQl9CYXJnYWluQmlufgoWd3FjkchVtkJTfTl/dw7C/Ks=
Referer: http://omitted by user/
Path: /Default.aspx]
[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) +106
System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +237
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
ASP.default_aspx.ProcessRequest(HttpContext context) in c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2e1de3e2\ec16856d\App_Web_default.aspx.cdcab7d2.2xg-fqvv.0.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
hope this helps. I am trying to get the attention of my web hosting company, but they are not answering my ticket. I really want to call them out, but I’ll restrain for now.
Robert
This issue was created by the webhosting company upgrading to AspNet 4.0 and my local dev project is targeting 3.5 sp1. I solved the viewstate issue by matching the target framework and it works great now. Just a suggestion to check the version as part of any trouble-shooting efforts.
thanks for the help, stackoverflow genius pool.