ASP.NET Custom Errors being ignored

不想你离开。 提交于 2019-12-31 02:34:27

问题


I have custom errors configured in my web.config, but IIS 6.0 is returning the custom error specified in the Custom Errors tab of the website configuration.

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

What can I be missing?


回答1:


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.




回答2:


You might be missing mode="On":

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



回答3:


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"/>


来源:https://stackoverflow.com/questions/497735/asp-net-custom-errors-being-ignored

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