【问题标题】:Validation of viewstate MAC failed after form submit表单提交后视图状态 MAC 的验证失败
【发布时间】:2015-04-15 16:36:57
【问题描述】:

所以我在一台计算机上出现此错误(而不是在其他两台计算机上):

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, [...]

它发生在开发计算机上,因此一切都在计算机上运行,​​“如果此应用程序由 Web Farm 或集群托管”的断言是 FALSE

根据 MSDN 博客,我应该删除表单的 action 属性(ask_full_report.aspx

<form id="form1" runat="server" method="post" action="full_report.aspx">

但我不想删除 action 属性,我想将我的表单提交给full_report.aspx

这是我的 Web.config(我删除了 appSettings 下的一些键)

<configuration>
  <appSettings>
    <add key="URL_BASE" value=""/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

对于this Answer:我不使用ViewStateUserKey

请问你有什么想法吗?

注意:我不认为它与

重复

额外资源:MSDN - HttpException Due to Invalid Viewstate After Installing .NET Framework 3.5 SP1


编辑:今天,没有采取任何行动,我不再有错误。我没有打开这篇文章,因为这个错误没有得到很好的记录。如果有人有解决方案,请发布答案。

【问题讨论】:

    标签: c# asp.net viewstate


    【解决方案1】:

    我刚刚遇到同样的问题,解决方案是将以下代码放在&lt;system.web&gt; 内的 web.config 中,如下所示

    <system.web>
    <machineKey validationKey="627BF72BB33AA8D28CA2C3E80920BA4DF0B726F97EEFBB0F4818350D63E6AFA380811F13ED1F086E386284654DB3"
    decryptionKey="F40B6E5A02B29A181D2D213B5ED8F50B73CFCFD0CC56E137" validation="SHA1" />
        </system.web>
    

    如果需要,请参阅this 以生成您自己的密钥

    【讨论】:

    • 知道为什么其他计算机不需要它吗?
    • 今天,没有采取任何行动,我不再有错误了。 (...)
    猜你喜欢
    • 1970-01-01
    • 2010-09-24
    • 2011-12-18
    相关资源
    最近更新 更多