表单提交后,viewstate MAC验证失败

时间:2015-04-15 16:36:57

标签: c# asp.net viewstate

所以我在一台计算机上有这个错误(而不是另外两台):

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

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

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

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

但我不想删除操作属性,我想将表单提交到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


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

1 个答案:

答案 0 :(得分:1)

我刚遇到同样的问题,解决方法是将以下代码放在<system.web>内的web.config中,如下所示

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

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

相关问题