当前位置: 首页 > news >正文

Validation of viewstate MAC failed. 解决方法

前段时间公司为了减轻服务器压力,对网页做了集群,分布在多台服务器,通过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" />

 

相关文章:

  • ajaxpro组件在windows2008 + IIS7 下不能正常使用的问题
  • 解决Http Handler在IIS6与IIS7中的问题
  • 如何将aspx页面保存为utf-8格式
  • JavaScript判断浏览器类型及版本
  • SQL中CONVERT转化函数的用法
  • Access to the path is denied
  • (ckeditor+ckfinder用法)Jquery,js获取ckeditor值
  • jquery+ie6中的form无法提交问题
  • SQL Server由于登录失败而无法启动服务的解决方法
  • 找不到可安装的ISAM
  • importing excel to sql datetime is null
  • 无法从带有索引像素格式的图像创建graphics对象
  • DELETE 语句与 REFERENCE 约束FK_ArticleTB_BlogAreaTB冲突。该冲突发生于数据库IConnectDB,
  • jquery获取ASP.NET服务器端控件dropdownlist和radiobuttonlist
  • 编程经验:定义了过多字段-Excel
  • JavaScript-如何实现克隆(clone)函数
  • 07.Android之多媒体问题
  • C++类中的特殊成员函数
  • CSS实用技巧
  • HTTP请求重发
  • JAVA_NIO系列——Channel和Buffer详解
  • JavaScript实现分页效果
  • JS数组方法汇总
  • miniui datagrid 的客户端分页解决方案 - CS结合
  • Stream流与Lambda表达式(三) 静态工厂类Collectors
  • windows下mongoDB的环境配置
  • windows下使用nginx调试简介
  • 从零搭建Koa2 Server
  • 分布式事物理论与实践
  • 给自己的博客网站加上酷炫的初音未来音乐游戏?
  • 开年巨制!千人千面回放技术让你“看到”Flutter用户侧问题
  • 可能是历史上最全的CC0版权可以免费商用的图片网站
  • 如何将自己的网站分享到QQ空间,微信,微博等等
  • 使用Envoy 作Sidecar Proxy的微服务模式-4.Prometheus的指标收集
  • ​​快速排序(四)——挖坑法,前后指针法与非递归
  • #QT(智能家居界面-界面切换)
  • #微信小程序(布局、渲染层基础知识)
  • #我与Java虚拟机的故事#连载01:人在JVM,身不由己
  • (Java实习生)每日10道面试题打卡——JavaWeb篇
  • (poj1.2.1)1970(筛选法模拟)
  • (附源码)springboot 智能停车场系统 毕业设计065415
  • (附源码)ssm基于jsp的在线点餐系统 毕业设计 111016
  • (七)Java对象在Hibernate持久化层的状态
  • (入门自用)--C++--抽象类--多态原理--虚表--1020
  • (三)uboot源码分析
  • (四)库存超卖案例实战——优化redis分布式锁
  • (原創) 如何讓IE7按第二次Ctrl + Tab時,回到原來的索引標籤? (Web) (IE) (OS) (Windows)...
  • (转)详解PHP处理密码的几种方式
  • ***linux下安装xampp,XAMPP目录结构(阿里云安装xampp)
  • ./indexer: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object fil
  • .gitignore
  • .NET 8.0 中有哪些新的变化?
  • .net core webapi Startup 注入ConfigurePrimaryHttpMessageHandler
  • .NET分布式缓存Memcached从入门到实战
  • .pop ----remove 删除