Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Validation of viewstate MAC failed.

Posted on 2010-11-09
6
Medium Priority
?
848 Views
Last Modified: 2012-05-10
Can someone please help me with this error that I'm getting.  I don't know what I'm doing wrong to generate this error or how to fix it.  Any help would be greatly appreciated.

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:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

  <%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
   <system.web>
       <compilation debug="true"/>
   </system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.  

Stack Trace:


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

[ViewStateException: Invalid viewstate.
      Client IP: 173.49.67.31
      Port: 4146
      User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.3; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
      ViewState: /wEPDwUKLTgwNjI5NDI4Ng9kFgICBg9kFhYCAQ8QDxYCHgtfIURhdGFCb3VuZGdkEBU/C0FCVk0gU2Nob29sJUFubnVhbCBNZW1vcmlhbCBNYXNzIGZvciB0aGUgRGVjZWFzZWQZQW5udWFsIFBhcmlzaCBHb2xmIE91dGluZxRBbm51YWwgU2VuaW9yIFNvY2lhbBtBcmNoYmlzaG9wIFJ5YW4gSGlnaCBTY2hvb2wbQXJjaGJpc2hvcCBXb29kIEhpZ2ggU2Nob29sFEJhY2sgVG8gU2Nob29sIE5pZ2h0B0JhcHRpc20NQmVlZiBhbmQgQmVlchlCZXJlYXZlbWVudCBTdXBwb3J0IEdyb3VwBUJpbmdvBUJpbmdvE0JsZXNzaW5nIG9mIEFuaW1hbHMsQy5BLlIuRS5TLiAoQmVmb3JlIGFuZCBBZnRlciBTY2hvb2wgUHJvZ3JhbSkWQ2FyZGluYWwgSnVzdGluIFJpZ2FsaQxDYXRlY2hldGljYWweQ0ZKIChDb250aW51aW5nIEZhaXRoIEpvdXJuZXkpCkNyYWZ0IEZhaXIKQ3ViIFNjb3V0cwpDWU8gU3BvcnRzFERvZGdlYmFsbCBUb3VybmFtZW50D0V2YW5nZWxpemF0aW9uIBVGYWJ1bG91cyA1NSBQbHVzIENsdWIURmlyc3QgSG9seSBDb...]

[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) +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
   ASP.adminevents_aspx.ProcessRequest(HttpContext context) +37
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
adminevents.aspx.vb
0
Comment
Question by:dyarosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 21

Expert Comment

by:Craig Wagner
ID: 34102338
Is the application being hosted in a load-balanced web farm? If so, you need to do what the error message is telling you (i.e. "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.").

Even if it's not being hosted in a cluster you can run into this problem if the worker process recycles between requests because a new machineKey will be generated when the worker process restarts. I would suggest using a fixed machineKey regardless.

You can read more about the how and why in this article: http://msdn.microsoft.com/en-us/library/ff649308.aspx.

There are several machinekey generators on the internet. I did a google search and here's the first one that came up: http://aspnetresources.com/tools/machineKey.
0
 

Author Comment

by:dyarosh
ID: 34103115
How can I tell if it is hosted in a web farm?  I currently rent a virtual server from GoDaddy.
0
 
LVL 21

Expert Comment

by:Craig Wagner
ID: 34103169
You could ask them, but why not just make the change and see if it fixes the problem? That's why I said in my original response, "Even if it's not being hosted in a cluster you can run into this problem ..." and "I would suggest using a fixed machineKey regardless."

FWIW, I ran into this problem with GoDaddy and just assumed they were either running on a web farm behind the scenes or recycling their app pool, so I went ahead and made the change and it fixed it.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:dyarosh
ID: 34105798
I read through the article and am still a little confused.  I checked my web.config file and I do not have the enableViewStateMac specified.  I've included a copy of what the <pages> part of my web.config contains in the code section.  I also do not have any machineKey tags in the web.config.
After reading the article it sounds like I need to do the following:
1. Change <pages> to <pages enableViewStateMac="true" viewStateEncryptionMode="Auto" ... />  (Do I include .../>?)
2. Add <machineKey validationKey="452359767C523E25EFE3C4B6E77525CF8882EE271FA4B240049BF8AF453F21C7C199919E955C4168869D9B2ADF25304A8AD6E3F562F20D84C841C372D113AB79" decryptionKey="8BF001841A582AA9F3A48005AB969E9C28CF9CA988328A07D55AE3232BEF57ED" validation="SHA1" decryption="AES" />  (I used your tool link to generate the machineKey).
Is this correct?



        <pages>
          <namespaces>
            <clear />
            <add namespace="System" />
            <add namespace="System.Collections" />
            <add namespace="System.Collections.Generic" />
            <add namespace="System.Collections.Specialized" />
            <add namespace="System.Configuration" />
            <add namespace="System.Text" />
            <add namespace="System.Text.RegularExpressions" />
            <add namespace="System.Linq" />
            <add namespace="System.Xml.Linq" />
            <add namespace="System.Web" />
            <add namespace="System.Web.Caching" />
            <add namespace="System.Web.SessionState" />
            <add namespace="System.Web.Security" />
            <add namespace="System.Web.Profile" />
            <add namespace="System.Web.UI" />
            <add namespace="System.Web.UI.WebControls" />
            <add namespace="System.Web.UI.WebControls.WebParts" />
            <add namespace="System.Web.UI.HtmlControls" />
          </namespaces>

          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          </controls>

        </pages>

Open in new window

0
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 2000 total points
ID: 34112598
Just do #2.

The article states:

    The relevant default settings are shown here for reference.

    <pages enableViewStateMac="true" viewStateEncryptionMode="Auto" ... />

In other words, the enableViewStateMac="true" and viewStateEncryptionMode="Auto" are the *default* settings. Adding them would be redundant, because as the default settings they are already in effect.

As for the "...", it simply means "there might be other stuff here but it's not important in this context." It's a common symbol used in writing that indicates a pause or "stuff that's not important left out." For example, if I were quoting something from the article I might write,

    "The default settings for the <pages> and <machineKey> elements ... The relevant default settings are
      shown here for reference."

That just means I left out part of the middle of the sentence that didn't add value or wasn't relevant to the point I was trying to get across when including the quote.
0
 

Author Closing Comment

by:dyarosh
ID: 34113398
Thank you for your help.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question