PDA

View Full Version : Validation of viewstate MAC failed


vagelis
08-28-2010, 05:31 AM
i receive an error when the site i dont do anything as client in site for ten minutes(more or less)

then if i click something i receive this 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:

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.



any idea why??
and what i have to do?

dmitri
08-28-2010, 07:40 AM
Please refer to the following post in our forum for the discussion of this problem and the ways to fix it:
http://forum.discountasp.net/showthread.php?t=2719

vagelis
08-28-2010, 09:31 AM
ok i choosed the solution of set the enableViewStateMac='false' and i think it works

i hope that is not a problem to not have enableViewStateMac='true'

vagelis
08-29-2010, 03:53 AM
i realized that i have problem again with tis issue

when i use enableViewStateMac='false' when the time passes and i click in a page to redirect i receive the message that it doesnot find the redirection page in my site

when i use
<compilation debug="false" strict="false" explicit="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies></compilation>

<pages enableViewStateMac="true">

<authentication mode="Windows">
<forms loginUrl="login.aspx" name="myappauth"/>
</authentication>

i receive again the message for
Validation of viewstate MAC failed

any idea??

wisemx
08-29-2010, 05:25 AM
Hi,
This can be one tough bear for sure.
Something that may work for you is to add a postback event like this:
http://www.andreas-kraus.net/blog/validation-of-viewstate-mac-failed/
All the best,
Mark

vagelis
09-11-2010, 01:17 AM
ok it works for me with this code

<compilation debug="true" strict="false" explicit="true">
<pages enableViewStateMac="true"/>
<machineKey validationKey="135265D42623958C1E84631D0AB327E8E433978BD4A28FC0A0 CD71E38A5F3D4F950DD32034058613CBFF0890211D4E6F4C6E 79EDC6A522572B31F3583DC5D929" decryptionKey="FE65F6B07ACA419BC98EC59992702913509ECDA570BDA0B866 43F4EE21643671" validation="SHA1" decryption="AES"/>


but in my page i have and a seconf web config inside a folder
what have i to do to fix and the second web config?

if i use the same i receive an error that has to do with the second machineKey in the project

latisha11
08-10-2011, 11:06 PM
Lots of people waiting for an answer to this one. Is it something that is know and being fixed or are we all just completely lost and should give up and go back to 1.1?

wisemx
08-11-2011, 05:16 AM
Well, imho, if ViewState is a nightmare for any project MVC3 may be the way to go.
All the best,
Mark

Jacob
08-12-2011, 07:32 AM
[QUOTE=vagelis;42009]ok it works for me with this code

<compilation debug="true" strict="false" explicit="true">
<pages enableViewStateMac="true"/>
<machineKey validationKey="135265D42623958C1E84631D0AB327E8E433978BD4A28FC0A0 CD71E38A5F3D4F950DD32034058613CBFF0890211D4E6F4C6E 79EDC6A522572B31F3583DC5D929" decryptionKey="FE65F6B07ACA419BC98EC59992702913509ECDA570BDA0B866 43F4EE21643671" validation="SHA1" decryption="AES"/>
Thanks, facing the same issue on my pc, this code ran for me too. Many thanks.