ASP.NET自定义错误被忽略 [英] ASP.NET Custom Errors being ignored
问题描述
我在我的web.config配置自定义错误,但IIS 6.0是返回的网站配置自定义错误选项卡中指定自定义错误。
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>
我能会丢失?
推荐答案
记住,在web.config中指定的404处理器只踢了由ASP.NET运行时处理的文件 - 名为.htm,图片,CSS, JavaScript的都将通过在主机中指定的404错误页面来处理IIS设置。
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.
如果您希望这些文件类型由您自定义错误处理,你需要设置IIS以404的直接到UrlRedirect.aspx。
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.
这篇关于ASP.NET自定义错误被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!