Solved

Validation of viewstate MAC failed when taking a while to postback

Posted on 2008-10-31
6
906 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
[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
 

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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

632 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