Search

Validation of ViewState MAC Failed when posting 'too quickly' by joteke

Closed
as Won't Fix Help for as Won't Fix

54
Sign in to vote
1
Sign in to vote
Sign in
to vote
Type: Suggestion
ID: 101988
Opened: 2/6/2006 9:26:36 PM
Access Restriction: Public
8
Workaround(s)
Hi,

You can get this Exception

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.]

when following preconditions are true:

-you know *for sure* that you aren't using a web farm
-it appears when using built-in databound controls such as GridView, DetailsView or FormView which utilize DataKeyNames.
-it appears if you have a large page which loads slowly for any reason

If following preconditions are true and you click a postbacking control/link while the Page hasn't loaded completely in client browser, you might get the "Validation of ViewState MAC failed" exception.

It appears because GridView using DataKeyNames requires ViewState to be encrypted. And when ViewState is encrypted, Page adds <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" /> field just before closing of the <form> tag. But this hidden field might not bet yet rendered to the browser with long-running pages, and if you make a postback before it "gets down", browser initiates postback without this field (in form post collection)

End result is that if this field is omitted on postback, Page doesn't "know" that viewstate is encrypted and causes the prementioned Exception. E.g Page expects to be fully-loaded before you can make a postback. And by the way similar problem is with event validation since __EVENTVALIDATION field is also rendered on the end of the form.

Reference:
http://forums.asp.net/1173230/ShowPost.aspx
http://aspadvice.com/blogs/joteke/archive/2006/02/02/15011.aspx
Details (expand)
Product Language
English
Version
Visual Studio 2005
Category
State Management
Operating System
Windows XP Professional
Operating System Language
English
Proposed Solution
Fix the rendering of the hidden marker form fields. Especially the Viewstate encryption one is only a flag, so it could be rendered on beginning of the form.
Benefits
Improved Security
Improved Reliability
Other Benefits
Improved Reliability
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/10/2006 at 3:10 AM
Thank you for your feedback. We are investigating this issue.

Thank you, VS2005 Product Team
Posted by Microsoft on 2/10/2006 at 3:26 AM
Thank you for your feedback. We are investigating this issue.

Thank you, VS2005 Product Team
Posted by joteke on 3/29/2006 at 9:09 PM
What's the status with this (almost 2 motnhs since submission)? There's been quite a lot of concerns & issues on ASP.NET Forums related to this one: http://forums.asp.net/thread/1173230.aspx (also in other type of scenarios) so in this light I might suggest this to be a bug instead of originally being a suggestion.
Posted by Microsoft on 3/30/2006 at 1:58 PM
Many thanks for your feedback. We are investigfating.

The Web Platform and Tools Team.
Posted by ziwez0 on 6/20/2006 at 9:23 AM
Is this issue still being looked into? It would be nice to have a 'fix' at soon!
Posted by CoralSpringsTony on 6/22/2006 at 1:19 PM
Almost the end of June and still no solution to this problem?????

What a huge letdown, when I converted my perfectly working 1.1 website to the new 2.0 website, only to find out in the first ten minutes that it has a major bug that Microsoft can't figure out for months.

Didn't anyone betatest this? Surely you didn't rush the product out the door cause you needed the money.

Let me know if you are close to fixing this. If not, I will throw 2.0 in garbage can and reinstall 1.1

Tony
CoralSpringsTony@hotmail.com
Posted by joteke on 10/21/2006 at 10:54 AM
Guys and gals,

what's the status with this one? Are you going to a) provide this workaround as proposed solution for now and/or b) are you going to change something for example in vNext to overcome this?

Thanks,

Teemu
Posted by buzzvista on 1/21/2007 at 3:38 AM
i have the same thing happen to me
Posted by Microsoft on 1/29/2007 at 3:21 PM
Thanks for your feedback on the .NET Framework! S. Somasegar, the Developer Division VP recently wrote in his blog (http://blogs.msdn.com/somasegar/archive/2006/05/18/601354.aspx) on how the next release of the .NET Framework (codename “Orcas”) requires a high degree of backward compatibility and therefore, how we are being very strict about the number and scope of bugs that are fixed and features that are added in the “Red Bits” during Orcas. Unfortunately, this bug falls into the red bits category, and so we are not able to address it in Orcas due to the potential for it to introduce compatibility issues.

However there are some work arounds that can mitigate the problem. These are throughly discussed at http://forums.asp.net/1173230/ShowPost.aspx.

We recognize you submitted this bug because of a specific problem you are experiencing with the product. If you submitted this bug because of a blocking problem you’re experiencing and continue to experience, you may want to contact Microsoft Professional Services http://support.microsoft.com. Alternatively you may find additional information by searching or posting to the ASP.NET forums (http://forums.asp.net) . Finally, if you submitted this bug because of a blocking problem you’re experiencing and continue to experience, you may want to also open a support call with Microsoft Professional Services (http://support.microsoft.com/?LN=en-us&scid=gp%3Ben-us%3Bofferprophone&x=8&y=14), which is a better support option when you’re experiencing business impact for your problem and are unable to resolve it in a timely manner on forums or other support channels.

Before starting work on the next full release of the .NET Framework, we will review the Connect data to help us identify and address the top customer reported issues. We’ll broadly review all bugs submitted to date at that time.

Mir Tariq
UI Frameworks Team
Posted by Edeuser on 6/19/2007 at 7:21 AM
I really need this to be resolved, there are multiple sites on the 2.0 framework and this is a huge issue. Please advise.
Posted by Developer Jeff on 8/6/2007 at 4:37 AM
Well... this is not the most perfect answer, but I have a workaround to post:

(solves the problem in IE, anyways... isn't that all anyone ever uses??) =o)

<meta http-equiv="Page-Enter" content="RevealTrans(Duration=0,Transition=0)" />

Essentially, including this tag in the header of your page disables the use of the page until it has completely downloaded to the browser. Our users don't seem to mind, in fact, they prefer it over the old way because it reduces the "flicker" effect they were getting on postbacks.