IIS 7.0 doesn't display custom error pages

前端 未结 4 1301
太阳男子
太阳男子 2021-02-07 18:52

I\'m running an application that has its own error handlers. Error pages are displayed properly while testing in dev environment (error pages are displayed properly).
Howe

相关标签:
4条回答
  • 2021-02-07 19:25

    I found out that the <system.webServer> section can let the request pass through. Then, my app can display my custom page. You can use these lines in your Web.Config:

    <system.webServer>
      <httpErrors existingResponse="PassThrough" />
    </system.webServer>
    

    You can also read the extended version to know What to expect from IIS7 custom error module.

    0 讨论(0)
  • 2021-02-07 19:30

    Well It turned out that in order to force IIS 7 to show custom pages the following lines should be added to web.config file.

    Put in system.webServer section

    <httpErrors errorMode="Detailed"> <!-- this is impornant -->
    <!-- Some custom error pages url go here -->
    </httpErrors>
    
    0 讨论(0)
  • 2021-02-07 19:44

    There is a setting in the applications Web.config file to set the debug mode:

    Default is:

    <customErrors mode="RemoteOnly" />
    

    Try setting it to "Off" (Note: the value is case sensitive!)

    <customErrors mode="Off" />
    

    I'm not sure if this setting is respected by IIS7, but since you see different behaviour on your development environment from the deployed, this was my fist guess. To test if this is the case, you can try to run your dev app from a different machine in your network if you have that possibility.

    0 讨论(0)
  • 2021-02-07 19:48

    Awe is right (+1), but in addition: IIS 7 has special handling described in the blog post you linked and this MSDN article. If you are using HandleErrorAttribute on your action, this is already done for you. If not, you'll need to set:

    filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
    

    ...yourself.

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