Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Validation of viewstate MAC failed when taking a while to postback

Posted on 2008-10-31
6
Medium Priority
?
913 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 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 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