HttpError will not show custom error pages

前端 未结 5 1269
独厮守ぢ
独厮守ぢ 2020-12-31 09:46

I\'ve got this in the web.config:


  
  

        
相关标签:
5条回答
  • 2020-12-31 10:06

    Ensure that you have the proper feature setting for the Error Page redirection in IIS. To check this, from the Error Pages page in IIS Manager, click Edit Feature Settings and make sure Custom error pages is checked if you are testing the redirects from the web server itself. If you are testing remotely, you can leave Detailed errors for local requests and custom error pages for remote requests is checked. This appears to be the default option in my test environment.

    0 讨论(0)
  • 2020-12-31 10:11

    You may also need to set the existingReponse attribute in the httpErrors element like this:

    <httpErrors errorMode="Custom" existingResponse="Replace">
      <clear />
          <error statusCode="404" prefixLanguageFilePath="" path="/ErrorHandler.aspx" responseMode="ExecuteURL" />
      <error statusCode="500" prefixLanguageFilePath="" path="/ErrorHandler.aspx" responseMode="ExecuteURL" />
    </httpErrors>
    
    0 讨论(0)
  • 2020-12-31 10:13

    If you are using ExecuteURL, the custom error page path must be in the same application pool as the application itself.

    For architectural reasons, IIS 7.0 can only execute the URL if it is located in the same Application Pool. Use the redirect feature to execute a Custom Error in a different Application Pool.

    0 讨论(0)
  • 2020-12-31 10:20

    This is how I am using it and it works to me, it looks pretty similar except for the subStatusCode directives and the ExecuteURL.

    
    <httpErrors>
         <!--Remove inherited 500 error page setting -->
         <remove statusCode='500' subStatusCode='-1'/> 
         <!--Override the inherited 500 error page setting with the 'My500.html' as its path-->
         <error statusCode='500' subStatusCode='-1' prefixLanguageFilePath='' path='/My500.html' responseMode='ExecuteURL'/> 
    </httpErrors>
    
    0 讨论(0)
  • 2020-12-31 10:21

    It seems as though you are using a server relative URL, try setting responseMode="ExecuteURL", from MSDN.

    ExecuteURL

    Serves dynamic content (for example, an .asp file) specified in the path attribute for the custom error. If responseMode is set to ExecuteURL, the path value has to be a server relative URL. The numeric value is 1.

    Redirect

    Redirects client browsers to a the URL specified in the path attribute that contains the custom error file. If responseMode is set to Redirect, the path value has to be an absolute URL. The numeric value is 2.

    0 讨论(0)
提交回复
热议问题