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.
臭名昭著的错误经过广泛的搜索,我无法找到任何解决我的具体问题。我在.NET 4中使用URL路由,但我没有使用MVC。我发现的所有问题/解决方案都是类似的(由于URL路由),所以在MVC中提供了解决方案,但不是在常规的ASP.NET Web窗体中。
的堆栈溢出问题笔记:
It seems to be related to the number of sub-paths in the url. If there are at least 2 sub-paths the viewstate validation fails.
在测试这个理论,我是能够提供一个快速和肮脏的工作,各地通过简单地从
Module/Search/Results
改变我的路线到
Module/SearchResults
暂时解决了这个问题,但是,那篇文章中的答案都没有帮助。
有趣的事情我发现,错误可以在IE9中重现,但不能在Chrome 24.0.1313.52m中重现。这导致我相信这个错误是浏览器特定的,所以我尝试为我的网站设置NoCache,但无济于事,Chrome仍然工作,IE9仍然抛出ViewState错误。
为了重现该问题,这里有一些关键因素,我的环境:
Windows 7 64-bit
IIS 6.1 SP 1
Local Web Project (VS 2010)
Nested Master Pages (3 levels)
URL Routing (defined in Global.asax)
Page contains a GridView with a TemplateField.
GridView has PagerSettings defined.
Links causing the error are within the TemplateField.
Links outside of the GridView do not cause the error.
重现步骤如下:
User browses to page "~/Module/Search/Results" (from link or directly doesn't matter)
User clicks on a button that posts back and causes a redirect to another page "~/Module/DoSomething"
User presses the Back button in the browser which takes them back to "~/Module/Search/Results"
User then proceeds to press a button that causes a post-back which immediately causes the error.
UPDATE: Added information in the key factors regarding the layout of the page.
我怎样才能解决这个问题问题,以便我可以在网页的网址中有2个或更多子路径,而不会在用户返回页面时导致错误,然后生成另一个帖子?
我设法找到这个:http://blogs.msdn.com/b/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx。这有帮助吗(它涉及到webforms)。 –
不幸的是,没有。在ViewState加载之前用户按下按钮(我给了足够的时间加载)似乎并不是一个问题。但是,将EnableViewStateMac设置为false会产生错误“状态信息对于此页无效,并且可能已损坏。”正如你的链接在开头提到的那样,但其余部分似乎并不适用。 (尝试了您的链接中的基本页面和其他建议) –