asp.net - 编辑 web.config 后出现 HTTP 错误 500

标签 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>

最佳答案

位置必须位于 configSections 下方

关于asp.net - 编辑 web.config 后出现 HTTP 错误 500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8179058/

相关文章:

c# - 如何根据浏览器接受的语言自动设置文化?

C# - 使用互斥锁的锁定问题

c# - 我应该在部署机器上安装 asp.net mvc 2 吗?

javascript - 在其他变量的函数中访问数据的变量 - 未定义

iis-7 - 通过 C# 进行 IIS 7 远程管理

asp.net-mvc - 创建 Asp.net MVC 3 应用程序时找不到关于 UrlRoutingModule 的 <modules>

asp.net - 在 Azure 上部署网站时未加载字体

asp.net - 如何在 Web 窗体 .NET Web 应用程序下配置嵌套 MVC 应用程序

asp.net - Multipart和Form在客户端上传方面的区别

asp.net - 如何解决子 Web 应用程序上嵌套的冲突 web.config 条目?