编辑web.config后的HTTP错误500

时间:2011-11-18 07:23:07

标签: asp.net iis-7 web-config

<location>标记添加到web.config(ASP.NET 4)后,我得到了HTTP 500 Internal Server Error,当我删除<location>时,它就可以了。

<?xml version="1.0"?>

<configuration>

  <location path="man">
    <system.web>
      <authorization>
        <allow users="man"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>

    <configSections>
      <section name="rewriter"
               requirePermission="false"
               type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
    </configSections>

    <system.web>
        <compilation debug="true" targetFramework="4.0" />

        <authentication mode="Forms">
          <forms    name=".ASPXAUTH"
                  loginUrl="Login.aspx"
                  protection="All"
                  timeout="30"
                  path="/"
                  requireSSL="false"
                  slidingExpiration="true"
                  defaultUrl="Login.aspx"
                  cookieless="UseCookies"
                  enableCrossAppRedirects="false"/>
        </authentication>

        <httpModules>
          <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
        </httpModules>

    </system.web>

  <system.webServer>

    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
    </modules>

    <validation validateIntegratedModeConfiguration="false" />

  </system.webServer>

  <rewriter>
    <rewrite url="~/man/(.+)" to="~/man/$1" processing="stop" />
    <rewrite url="~/man/^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd)(\?.+)?)$" to="~/man/$1" processing="stop" />
    <rewrite url="~/files/^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd|\.pdf|\.doc|\.ppt)(\?.+)?)$" to="~/files/$1" processing="stop" />
    <rewrite url="~/man/" to="~/man/default.aspx" processing="stop"/>
    <rewrite url="~/style/(.+)" to="~/style/$1" processing="stop" />
    <rewrite url="~/images/(.+)" to="~/images/$1" processing="stop" />
    <rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd)(\?.+)?)$" to="$1" processing="stop" />
    <rewrite url="~/(.+)" to="~/default.aspx?pn=$1" />
  </rewriter>

</configuration>

1 个答案:

答案 0 :(得分:3)

位置必须低于configSections