前段时间公司为了减轻服务器压力,对网页做了集群,分布在多台服务器,通过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://blog.csdn.net/wrongfu964/article/details/3896991

MachineKey生成方法

打开以下网址:http://www.aspnetresources.com/tools/keycreator.aspx

点击:Generated

生成的Machinekey:

MachineKey

<machineKey
validationKey="86B6275BA31D3D713E41388692FCA68F7D20269411345AA1C17A7386DACC9C46E7CE5F97F556F3CF0A07159659E2706B77731779D2DA4B53BC47BFFD4FD48A54"
decryptionKey="9421E53E196BB56DB11B9C25197A2AD470638EFBC604AC74CD29DBBCF79D6046"
validation="SHA1"
decryption="AES"
/>

MachineKey的使用方法:

将MachineKey添加至Web.config文件的<system.web></system.web>之间

MachineKey的作用:

  1. ASP.net 使用 forms authentication 时的 cookie 数据的加密和解密。以确保这部分数据不会被篡改
  2. viewstate 数据的加密和解密。以确保这部分数据不会被篡改。
  3. 使用进程外session(out-of-process session)时,对会话状态标识进行验证。

更多详细信息请参考:

http://www.wonima.com

http://msdn.microsoft.com/zh-cn/library/ms998288(en-us).aspx

Validation of viewstate MAC failed machinekey生成、使用方法的更多相关文章

  1. Validation of viewstate MAC failed 解决办法

    大部分人都说是在页里或web.config里加EnableEventValidation="false" EnableViewStateMac="false" ...

  2. Validation of viewstate MAC failed. 解决方法

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

  3. ”Validation of viewstate MAC failed” 错误

    ”Validation of viewstate MAC failed” 错误 在ASP.NET里面,View State使用较为广泛.它作为一个隐藏字段,可以帮助服务端”记住“客户端的改变,这样客户 ...

  4. 转:Validation of viewstate MAC failed异常的原因及解决方法

    ViewState是一种机制,ASP.NET 使用这种机制来跟踪服务器控件状态值,否则这些值将不作为 HTTP 窗体的一部分而回传.也就是说在页面刷新或者回传的时候控件的值将被清空,我们在aspx.c ...

  5. 一个有趣的 ”Validation of viewstate MAC failed” 错误的发现和解决

    在ASP.NET里面,View State使用较为广泛.它作为一个隐藏字段,可以帮助服务端”记住“客户端的改变,这样客户端 收到服务器对PostBack的响应后,仍然可以展现在PostBack之前设定 ...

  6. Mac系统Git生成ssh公钥

    Mac系统Git生成ssh公钥 在使用Git仓库进行代码管理时,新的电脑上往往需要生成ssh公钥进行匹配,Mac系统生成Git公钥过程如下: 1.检查本机是否已有公钥 在终端中输入如下命令: ? 1 ...

  7. machinekey生成工具 v1.0 官方最新版

    http://www.33lc.com/soft/66056.html 电信下载 广东电信下载 厦门电信下载 湖北电信下载 江苏电信下载 网通下载 陕西网通下载 山东网通下载 甘肃网通下载 山西网通下 ...

  8. 【转载】取得系统中网卡MAC地址的三种方法

    From:http://blog.csdn.net/zhangting1987/article/details/2732135 网卡地址这个概念有点混淆不清.因为实际上有两个地址,mac地址和物理地址 ...

  9. 设置SVN,Git忽略MAC的.DS_Store文件的方法

    设置SVN,Git忽略MAC的.DS_Store文件的方法 I. 显示Mac隐藏文件的命令: defaults write com.apple.finder AppleShowAllFiles -bo ...

随机推荐

  1. Zookeeper理解

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等.Zookeeper是hadoop的一个子项目,其 ...

  2. Chapter 2 Open Book——30

    I looked down. His hands were clenched into hard fists again. 我向下看,他的双手又一次收紧握成拳头. Mr. Banner came to ...

  3. 第八十九节,html5+css3pc端固定布局,热门旅游取,标题介绍区,旅游项目区

    html5+css3pc端固定布局,热门旅游取,标题介绍区,旅游项目区 样式: html代码: <!--主体--> <section class="zhu-ti" ...

  4. 常用的HTTP状态码如下

    成功的状态码: – 服务器成功返回网页 – 未修改 失败的状态码: – 请求的网页不存在 – 服务器暂时不可用 – 服务器内部错误 下面的不是很常用,记住上面那几个就ok了,有bug了再补充 其他的状 ...

  5. 数据库DateTime类型为空的处理

    一,写一个辅助类,将该方法设为静态,先装换为object,在转为DateTime,返回DateTime public class DateTimeHelper { public static Date ...

  6. iOS开发中怎么样使用激光推送

    1.注册激光推送的账号 ----> 创建应用 2.上传推送测试和发布的p12文件  注意密码的填写 3.下载sdk并拖进工程里 4.在build setting 搜索search   把路径改一 ...

  7. hdfs zkfc –formatZK 之HadoopIllegalArgumentException: Bad argument: –formatZK

    HadoopIllegalArgumentException: Bad argument: –formatZK从某文档中拷贝的命令,粘贴过来使用的,“–formatZK”有问题解决方法:手工输入此命令 ...

  8. PHP文本路径转换为链接文字

    <?php /** * 文本路径转换为有链接的文字 * @param string $str 转换内容 * @return string */ function urlToLink($str) ...

  9. wpf 数据绑定的4种形式

    1.source 2.element 3.relativesource 4.datacontent

  10. lepus监控OS配置

    Lepus通过snmp协议进行对操作系统数据采集,因此需要在监控机和被监控机开启snmp服务 snmp协议:简单网络管理协议(SNMP,Simple Network Management Protoc ...