简体   繁体   English

IIS7.5 URLRewrite在自定义404错误页面上不起作用

[英]IIS7.5 URLRewrite not working on custom 404 Error page

I am using URL Rewrite on IIS 7.5 to hide the server disclosure header for an ASP.NET Webforms application and everything is working fine in my main application. 我在IIS 7.5上使用URL重写来隐藏ASP.NET Webforms应用程序的服务器公开标头,并且在我的主应用程序中一切正常。 However, on custom error handling, the rewrite is not firing at all. 但是,在自定义错误处理上,根本不会触发重写。

In my web.config: 在我的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>

Also in the section: 也在本节中:

<modules runAllManagedModulesForAllRequests="true" />

HTTP Errors: HTTP错误:

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

Custom errors: 自定义错误:

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

On the custom 404 page, it simply looks for a couple of values for processing a login attempt. 在自定义404页上,它仅查找用于处理登录尝试的几个值。 If no values are found, it displays an error message to the user. 如果找不到任何值,它将向用户显示一条错误消息。

Is there something I'm missing? 有什么我想念的吗?

Actually found a great answer to this elsewhere. 实际上在其他地方找到了一个很好的答案。 The issue was to do with an internal redirection to the 404 page, which appeared to bypass URLRewrite completely. 问题与内部重定向到404页面有关,该页面似乎完全绕过了URLRewrite。

Using ExecuteURL as 404 handler in web.config will bypass URL Rewrite (ie.. outboundRules) while using other responseModes won't 使用ExecuteURL作为web.config中的404处理程序将绕过URL重写(即outboundRules),而使用其他responseModes则不会

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM