Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 17964|回复: 0

Validation of viewstate MAC failed. 解决方法

[复制链接]
  • TA的每日心情
    奋斗
    2024-4-6 11:05
  • 签到天数: 748 天

    [LV.9]以坛为家II

    2034

    主题

    2092

    帖子

    70万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    705612
    发表于 2021-4-11 17:52:05 | 显示全部楼层 |阅读模式

    前段时间公司为了减轻服务器压力,对网页做了集群,分布在多台服务器,通过DNS轮回解析到各台服务器,结果页面只要打开停留到DNS解析到下一个地址,就会出现出下错误信息。

     

    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.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information 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 <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

    Source Error: 

    The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

    1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

      <%@ Page Language="C#" Debug="true" %>

    or:

    2) Add the following section to the configuration file of your application:

    <configuration>
       <system.web>
           <compilation debug="true"/>
       </system.web>
    </configuration>

    Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

    Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.


    Stack Trace: 

    [HttpException (0x80004005): Unable to validate data.]
       System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +294
       System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +203
    
    [ViewStateException: Invalid viewstate. 
    	Client IP: 218.28.26.86
    	Port: 45262
    	User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; FDM)
    	ViewState: /wEPDwUKLTQzMDM1NDM2MA9kFgRmDxYCHgRUZXh0BdEbdmFyIHNBcnIgPSBuZXcgQXJyYXkoKTtzQXJyWzE1XT1uZXcgQXJyYXkoKTtzQXJyWzE1XVswXT0xO3NBcnJbMTVdWzFdPWZhbHNlO3NBcnJbMTVdWzNdPTA7c0FyclsxNV1bMl09dHJ1ZTtzQXJyWzM4XT1uZXcgQXJyYXkoKTtzQXJyWzM4XVswXT0wO3NBcnJbMzhdWzFdPXRydWU7c0FyclszOF1bM109MTtzQXJyWzM4XVsyXT10cnVlO3NBcnJbN109bmV3IEFycmF5KCk7c0Fycls3XVswXT0yO3NBcnJbN11bMV09ZmFsc2U7c0Fycls3XVszXT0wO3NBcnJbN11bMl09dHJ1ZTtzQXJyWzZdPW5ldyBBcnJheSgpO3NBcnJbNl1bMF09MDtzQXJyWzZdWzFdPWZhbHNlO3NBcnJbNl1bM109MTtzQXJyWzZdWzJdPXRydWU7c0FyclszN109bmV3IEFycmF5KCk7c0FyclszN11bMF09MDtzQXJyWzM3XVsxXT10cnVlO3NBcnJbMzddWzNdPTE7c0FyclszN11bMl09dHJ1ZTtzQXJyWzEzXT1uZXcgQXJyYXkoKTtzQXJyWzEzXVswXT00O3NBcnJbMTNdWzFdPWZhbHNlO3NBcnJbMTNdWzNdPTA7c0FyclsxM11bMl09dHJ1ZTtzQXJyWzMzXT1uZXcgQXJyYXkoKTtzQXJyWzMzXVswXT0wO3NBcnJbMzNdWzFdPWZhbHNlO3NBcnJbMzNdWzNdPTE7c0FyclszM11bMl09dHJ1ZTtzQXJyWzM0XT1uZXcgQXJyYXkoKTtz...]
    
    [HttpException (0x80004005): 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.]
       System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +267
       System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +282
       System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
       System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
       System.Web.UI.HiddenFieldPageStatePersister.Load() +198
       System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83
       System.Web.UI.Page.LoadAllState() +35
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
       System.Web.UI.Page.ProcessRequest() +86
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
       System.Web.UI.Page.ProcessRequest(HttpContext context) +49
       ASP.admin_articleadd_aspx.ProcessRequest(HttpContext context) +4
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
    

     

     

     

     

     

    解决方法:

     

    解决方案(1) 

    处理页面增加 

    <%@ Page Language="C#"  enableViewStateMac="false" %> 


    解决方案(2)推荐 
    <machineKey validationKey="B8CEF0C74E23E7197FCC4C9E3617C0007D94D43C7F7A79C582C54B95D69B946DFD49CAF5AA72F9A8CA2CBA040A9DF64DC1DF90DAE1214AE4F1AB7FA56DD65C0D" decryptionKey="D7F1CE31847C4FB31EF51E14F3820D52B659AF8523FC932C03506CC075DB8B28" validation="SHA1" decryption="AES" />

    http://support.microsoft.com/kb/829743/zh-cn

    转自:http://blog.csdn.net/wrongfu964/article/details/3896991

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-5-15 15:07 , Processed in 0.070119 second(s), 29 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表