Validation of viewstate MAC failed- Server Error in '/' Application

天大地大妈咪最大 提交于 2019-12-31 03:25:27

问题


I got this error when i access my hosted web application(in VS2008 C# ASP.NET 3.5 Framework)

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.

The interesting thing is that there is no problem if we continue after login process. If you logged in and do nothing for 15 or 20 minutes, then click any menu...this error will be generated. So I doubt that it is related to session out. In my webconfig file I have written session time out as follows.

<sessionState timeout="15" />

How can I correct this error?


回答1:


There are a few ways to fix this issue, but some solutions are better than others. The fastest way is usually to add the following to the web.config:

<pages enableEventValidation="false" viewStateEncryptionMode="Never">

The problem with the above solution is that you sacrifice some security. The next "quick fix" is to add the following to the web.config, but there are drawbacks to this as well:

<pages enableViewStateMac="false">

If this application is hosted by a web farm or is otherwise distributed across multiple web servers, you should probably steer clear of that option.

In my opinion, the best overall solution is offered here.




回答2:


I believe that your problem is in App Pool "Idle timeout" field. You have to ask to your provider to change it to something greater... say 20mins

Take a look here.



来源:https://stackoverflow.com/questions/8181590/validation-of-viewstate-mac-failed-server-error-in-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!