ASP.NET Custom Errors being ignored

本秂侑毒 提交于 2019-12-02 01:51:18

Bear in mind that the 404 handler specified in the web.config only kicks in for files handled by the ASP.NET runtime - .htm, images, css, javascript will all be handled by the 404 page specified in your hosts IIS settings.

If you want these file types to be handled by your custom error, you'll need to set IIS to direct 404's to UrlRedirect.aspx.

You might be missing mode="On":

<system.web>
        <customErrors mode="On">
              <error statusCode="404" redirect="UrlRedirect.aspx" />
        </customErrors>
</system.web>

Actually, if I'm understanding your dilemma correctly, it sounds like the custom error IS being returned, if this is not what you want you will need to turn the mode to "Off" or "RemoteOnly" in order to see detailed error messages in your environment.

<customErrors mode="Off"/>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!