Solved

Validation of viewstate MAC failed when taking a while to postback

Posted on 2008-10-31
6
901 Views
Last Modified: 2012-05-05
I have ap age that has a number of dropdowns and textboxes that allow a user to enter a football team and the result of a fixture.

if you entyer the information quickly then every thing works fine and the page saves correctly.

however if you take a while to click the save button when you do so you get the error:
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:

I've tried reading up on this and the only thing that i thought may be applicable to me is the recycling of the application pool?

does this sound likely?

the user doesnt have too take an excessive long time to get this error so i need to get it sorted as it is becoming an iusse.

any ideas? i will post the full error page below
0
Comment
Question by:scm0sml
  • 3
  • 3
6 Comments
 

Author Comment

by:scm0sml
ID: 22854548
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) +2546748
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +214

[ViewStateException: Invalid viewstate.
      Client IP: 90.199.172.112
      Port: 63763
      User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; InfoPath.2)
      ViewState: /wEPDwUJNjEzMDY3ODk3D2QWAmYPZBYCAgMPZBYCAgEPZBYEAgMPEA8WBh4NRGF0YVRleHRGaWVsZAUHRml4dHVyZR4ORGF0YVZhbHVlRmllbGQFCUZpeHR1cmVJRB4LXyFEYXRhQm91bmRnZBAVBAlTZWxlY3QuLi43QWZhbiBMaWRvIHZzIFRhZmZzIFdlbGwgLSAxc3QgVGVhbSAtIFdlbHNoIExlYWd1ZSBEaXYgMVJUYWZmcyBXZWxsIEFGQyB2cyBUdXJiZXJ2aWxsZSBBcm1zIEZDICAtIFJlc2VydmUgVGVhbSAtIFNvdXRoIFdhbGVzIEFtYXRldXIgTGVhZ3VlR1RhZmZzIFdlbGwgdnMgQ3dtYnJhbiBDZWx0aWMgLSBZb3V0aCBUZWFtIC0gV2Vsc2ggTGVhZ3VlIFlvdXRoIERpdiBFYXN0FQQBMAMxNzUDMTg0AzE2MRQrAwRnZ2dnZGQCCw8WAh4HVmlzaWJsZWcWBgIBDw8WAh4EVGV4dAUJQWZhbiBMaWRvZGQCBw8PFgIfBAUKVGFmZnMgV2VsbGRkAg8PZBYgAgEPEA8WBh8ABQhGVUxMTkFNRR8BBQhQTEFZRVJJRB8CZ2QQFXgJU2VsZWN0Li4uGEFhcm9uICBUaG9tYXMgLSAxc3QgVGVhbRZBbGV4ICBOb3J0aCAtIDFzdCBUZWFtGkJhcnJ5ICBSaWNoYXJkcyAtIDFzdCBUZWFtG0N1cnRpcyAgTWF0dGhld3MgLSAxc3QgVGVhbRVEYWxlICBSZWVzIC0gMXN0IFRlYW0aRGF2ZSAgTWMgS2Vu...]

[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) +116
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +251
   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() +220
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83
   System.Web.UI.Page.LoadAllState() +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.admin_newresult_aspx.ProcessRequest(HttpContext context) +4
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
0
 
LVL 16

Accepted Solution

by:
MikeMCSD earned 500 total points
ID: 22854997

Go to this link: http://aspnetresources.com/tools/keycreator.aspx

Leave the defaults in place, validation key length 64, encryption key length 24, type sha1. Click Generate to create a random machine key for you and copy the result.

Now open the web.config file from your site.
And paste in the <machineKey ... />

<system.web>
<machineKey validationKey="6DF5E433D9405FB87840F9 ..........
decryptionKey="9BACA138B26E399751CE4132180179B874 ............

0
 

Author Comment

by:scm0sml
ID: 22856161
ok i will try that once i get in later.

do you mind giving me a brief explanation of the problem and how your link fixes it tho?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:scm0sml
ID: 22862047
this seems to have fixed the issue, the link you gave creates the key but there is no real explanation as to why i need it or what the problem was in the first place.

can you just give me a brief overview of the prob and how this key fixes it.

thanks
0
 
LVL 16

Expert Comment

by:MikeMCSD
ID: 23010578
The explanation is explained in the error:

  "this application is hosted by a Web Farm or cluster . . ."

there is nothing more to explain about it.
0
 
LVL 16

Expert Comment

by:MikeMCSD
ID: 23010645
Also, my solution solved the problem:

  "this seems to have fixed the issue .  . "       -  from scm0sml

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now