验证视图状态MAC失败

时间:2011-06-26 21:57:34

标签: asp.net viewstate

  未被捕的例外:[例外......   “'Sys.WebForms.PageRequestManagerServerErrorException:   Sys.WebForms.PageRequestManagerServerErrorException:   验证视图状态MAC失败。如果   此应用程序由Web托管   农场或集群,确保    配置指定   相同的validationKey和验证   算法。无法使用AutoGenerate   在群集中。'在调用方法时:   [nsIDOMEventListener ::的handleEvent]”   nsresult:“0x8057001c   (NS_ERROR_XPC_JS_THREW_JS_OBJECT)”   位置:“JS框架::   chrome://firebug/content/spy.js ::   callPageHandler :: line 744“data:no]

事情是,我甚至没有machineKey标签。我评论了它,我仍然得到这个错误。

这是我的整个web.config文件:

<?xml version="1.0"?>

<configuration>
  <configSections>
    <sectionGroup name="UrlRewriter">
      <section name="PlainRules" type="System.Configuration.NameValueSectionHandler"/>
      <section name="RegExRules" type="System.Configuration.NameValueSectionHandler"/>
    </sectionGroup>
  </configSections>

  <UrlRewriter>
    <PlainRules configSource="UrlRewriter.plain.config" />
    <RegExRules configSource="UrlRewriter.regex.config" />
  </UrlRewriter>

  <connectionStrings configSource="db.config"/>

  <system.net>
    <mailSettings>
      <smtp configSource="mail.config"/>
    </mailSettings>
  </system.net>

  <system.web>
    <!--<machineKey validationKey=""
                decryptionKey="" validation="SHA1" />-->

    <compilation debug="true" targetFramework="4.0" />
    <globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" />
    <trace enabled="false"/>
    <!--<customErrors defaultRedirect="~/error" mode="RemoteOnly"/>-->
    <httpRuntime maxRequestLength="4000" executionTimeout="1000"/>

    <authentication mode="Forms">
      <forms defaultUrl="~/" loginUrl="~/login" timeout="43200" protection="All"  cookieless="UseCookies" />
    </authentication>

    <membership defaultProvider="AspNetSqlMembershipProvider" hashAlgorithmType="SHA1">
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" applicationName="damnation" connectionStringName="membership"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Hashed"
             maxInvalidPasswordAttempts="20" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="5"
        />
      </providers>
    </membership>

    <roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="membership" applicationName="damnation"/>
      </providers>
    </roleManager>

    <profile defaultProvider="AspNetSqlProfileProvider" enabled="true" inherits="Damnation.Website.Shared.Membership.SharedMembershipProfile">
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="membership" applicationName="damnation"/>
      </providers>
    </profile>

    <httpModules>
      <add name="UrlRewriter" type="Damnation.Website.Shared.UrlRewriting.UrlRewriterModule"/>
    </httpModules>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>

    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRewriter" type="Damnation.Website.Shared.UrlRewriting.UrlRewriterModule"/>
    </modules>
  </system.webServer>
</configuration>

这可能是什么问题? 我还要提一下,我尝试使用和不使用重写器(我自己编写的小模块),所以这不是问题......

更新:当我尝试使用成员资格登录时,firebug会捕获此问题,这会导致更新面板中的回发。

1 个答案:

答案 0 :(得分:0)

如果您的配置中没有machineKey,则使用machine.config中的machineKey。

此网站是否在Web场中设置?如果是这样,您应该生成machineKey并将其放入您站点的所有web.config文件安装中。