【问题标题】:IIS7.5 URLRewrite not working on custom 404 Error pageIIS7.5 URLRewrite 在自定义 404 错误页面上不起作用
【发布时间】:2018-06-08 19:00:04
【问题描述】:

我在 IIS 7.5 上使用 URL 重写来隐藏 ASP.NET Webforms 应用程序的服务器披露标头,并且在我的主应用程序中一切正常。但是,在自定义错误处理中,重写根本不会触发。

在我的 web.config 中:

    <outboundRules>
        <remove name="Remove Server header" />
        <rule name="Remove Server header" enabled="true">
            <match serverVariable="RESPONSE_SERVER" pattern=".+" />
            <action type="Rewrite" value=" " />
        </rule>
    </outboundRules>

也在该部分中:

<modules runAllManagedModulesForAllRequests="true" />

HTTP 错误:

<httpErrors errorMode="Custom">
  <remove statusCode="404" />
  <error statusCode="404" responseMode="ExecuteURL" path="/404Check.aspx" />
</httpErrors>

自定义错误:

  <customErrors mode="On" >
      <error statusCode="404" redirect="~/404Check.aspx"/>
 </customErrors>

在自定义 404 页面上,它只是查找几个值来处理登录尝试。如果没有找到值,它会向用户显示一条错误消息。

我有什么遗漏吗?

【问题讨论】:

    标签: asp.net url-rewriting iis-7.5


    【解决方案1】:

    实际上在其他地方找到了一个很好的答案。问题与到 404 页面的内部重定向有关,这似乎完全绕过了 URLRewrite。

    Using ExecuteURL as 404 handler in web.config will bypass URL Rewrite (ie.. outboundRules) while using other responseModes won't

    【讨论】:

      猜你喜欢
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-17
      • 2011-12-23
      • 2014-01-02
      • 1970-01-01
      相关资源
      最近更新 更多