开发者

How I can fix MAC error in asp.net application?

开发者 https://www.devze.com 2023-02-15 19:10 出处:网络
I have an ASP.NET application all things are working fine but after some minutes when I click on a button it gives me this error :

I have an ASP.NET application all things are working fine but after some minutes when I click on a button it gives me this error :

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. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more in开发者_开发百科formation about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 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.

How I can resolve this ?


This blog post covers this in quite a bit of detail:
http://www.eukhost.com/forums/f15/fix-validation-viewstate-mac-failed-6085/

In the past i've used this method:

  <system.web>
  <pages enableViewStateMac="false" />
  </system.web>


setting enableviewstatemac to false means if the encoded view state changes your view state won't be replaced with the older one, this can be a security issues. instead of this, after seeing your error put a persistence machine key in web.config if you are in web farm scenario because dynamically generated machine key tends to view_state error.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号