随笔-75  评论-74  文章-35  trackbacks-1
这两天极度的郁闷,以前做的一个asp.net项目出现Validation of viewstate MAC failed 错误。
但是我当时去部署的时候全部都测试过了。
找了很多Validation of viewstate MAC failed 的资料,都说是ViewState加密的问题,但是按照网上说的,改来改去就是不行。

而且我放到我的电脑上,和我们的服务器上运行也是正常的,并没有出现错误。
然后客户说在他的电脑上配置也出错。

突然想起来了,.net3.5和.net2.0的版本号是一样的,我当时看到版本号是一样的我没有注意这个问题,是不是安装.net3.5后造成的?
确认了一下,果然,客户自己的电脑和服务器都装上了.net3.5。
找到问题根源就好办了。虽然经历了一段折磨。

在网上搜索了一下,还是老外这方面 反应比较快,找到了一个相同问题的贴 。

Validation of viewstate MAC failed after installing .NET 3.5 SP1

Cause:

This will happen if you have specified an action on the forms element, and if the action is different than the page you are browsing to, i.e. in this case the page I am browsing to is Default3.aspx, but the action is set to Default.aspx (as you can see from the Path and Referer in the error message)

<form id="form1" runat="server" action="Default.aspx">

 

The reason this occurs after installing SP1 for .NET 3.5 is because prior to this service pack, the action attribute was ignored.   Now that it is no longer ignored, the post-back will actually post back to the action page, and of course the view state for Default3.aspx will not be valid for Default.aspx.

You’ve heard it before:)  this is not a bug, it’s a feature…  in this case that’s actually true…

 

Resolution:

Remove the action attribute, or change it to post to the right page if you want to have viewstate enabled.

 

Laters,
Tess

确实是在错误页面中出现了action的属性,我记得 我当时好像没有加过啊, 去掉他,一切OK

痛苦ing~~~~~~   欣喜ing~~~~~~~

posted on 2009-10-29 16:17 影子 阅读(389) 评论(1)  编辑  收藏 所属分类: asp.net点滴

评论:
# re: 服务器上安装.net3.5后出现 Validation of viewstate MAC failed 错误[未登录] 2009-12-31 10:44 | 路人甲
非常感谢,按照你的方法,我已经解决了问题。..  回复  更多评论