【问题标题】:Validation of viewstate MAC failed - load balance environment视图状态 MAC 验证失败 - 负载平衡环境
【发布时间】:2012-10-16 09:52:00
【问题描述】:

我的网站托管在一个网络场上,该场处于负载平衡(总共 4 个服务器)环境中,但是 我的一些客户遇到以下错误:

Server Error in '/' Application.
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.

但是,我的四个站点中的每一个都在 web.config 文件中具有以下机器密钥,但仍然遇到问题。

<machineKey
    validationKey="3B1107F98F6E4ECD868C929C0826C3845058F39B5113CD7E676170F4DBE4D65D83C65BCB166FFFB7F2749214C0CA503D04A956C1681F56C63A2B5D9F5F4B04FC"
    decryptionKey="3565248537BB78D03CCA78A2E8C757451EDCFD3D7AAE6199420FEE692158B37F"
    validation="SHA1" decryption="AES"
    />

有什么建议吗?谢谢

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    我从这里 Validation of viewstate MAC failed- Server Error in '/' Application 拿走它。

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

    上述解决方案的问题是你牺牲了一些 安全。下一个“快速修复”是将以下内容添加到 web.config,但这样做也有缺点:

    <pages enableViewStateMac="false">
    

    以上代码都可以解决你的问题。

    【讨论】:

    • 这两个建议都可以用于开发环境,但不建议用于生产环境。
    猜你喜欢
    • 1970-01-01
    • 2010-09-24
    • 2011-12-18
    相关资源
    最近更新 更多