简体   繁体   English

验证ViewState MAC失败

[英]Validation of ViewState MAC Failed

Sorry if this is duplicate but I've been going crazy for the past two hours over this. 很抱歉,如果这是重复的,但是在过去的两个小时里,我一直在为此疯狂。

After changing the Master Page in ASP.NET MVC 1.0 application, I keep getting this familiar error when I try a postback without filling in the mandatory form elements which are validated by the server: 在ASP.NET MVC 1.0应用程序中更改母版页后,当我尝试回发而未填写由服务器验证的必填表格元素时,我一直收到此熟悉的错误:

"Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster." “对视图状态MAC的验证失败。如果此应用程序由Web Farm或群集托管,请确保配置指定相同的validationKey和验证算法。AutoGenerate不能在群集中使用。”

The new page refers to a lot of jQuery code with lightboxes, superfish etc. Could that be a problem while doing a postback? 新页面引用了许多带有灯箱,superfish等的jQuery代码。在做回发时会出现问题吗?

If I revert back to the original master, the error disappears and I'm able to validate form fields. 如果我恢复到原来的母版,错误将消失并且我可以验证表单字段。 Both masters are located in the same path. 两个主机都位于同一路径中。

I know a lot of other guys have faced this issue but I was unable to find anything which could help me. 我知道很多其他人都遇到过这个问题,但是我找不到任何可以帮助我的东西。

Thanks. 谢谢。

Edited and added 编辑并添加

After a little debugging, I've realized that a directive in the master page: 经过一些调试后,我意识到母版页中的指令:

<% Html.RenderAction("menu", "nav"); %>

is creating the problem. 在制造问题。 The directive asks the "menu" action of the controller "nav" to inject a partial view Menu.ascx. 该指令要求控制器“ nav”的“菜单”动作注入部分视图Menu.ascx。 If I delete this line from the new master page, everything works OK. 如果我从新的母版页删除此行,一切正常。 My app's left bar navigation relies on this directive to work properly. 我的应用程序的左栏导航依赖于此指令才能正常工作。 Is there any way I can get around this? 有什么办法可以解决这个问题? Very mysterious. 很神秘

Are you using Html.AntiForgeryToken() anywhere on this page? 您是否在此页上的任何地方使用Html.AntiForgeryToken()? Sometimes when I am testing locally with multiple different sites and / or port changes this will happen to me. 有时,当我在本地使用多个不同的站点进行测试和/或更改端口时,这会发生在我身上。 If it does I clear my browser cache and it works just fine. 如果可以的话,我会清除浏览器缓存并正常运行。

I did experienced the same problem two days ago . 两天前我确实遇到了同样的问题。 :) :)

A simple restart of the box has worked in my case so I did'nt investigate further. 在我的情况下,只需重新启动即可,因此我没有做进一步调查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM