自定义错误页不显示 [英] Custom Error Page not showing

查看:156
本文介绍了自定义错误页不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,当我得到一个ASP.NET运行时错误,这不是我的加载自定义错误页

 <的customErrors模式=ON的defaultRedirect =app_offline.htmredirectMode =ResponseRewrite>
    <错误状态code =404重定向=app_offline.htm/>
        <错误状态code =500重定向=app_offline.htm/>
< /&的customErrors GT;

这是在我的web.config。

我仍然得到这个虽然,它不是我的加载错误.htm页:

 在'/'应用程序的服务器错误。
运行时错误
说明:服务器上出现应用程序错误。此应用程序prevent当前自定义错误设置的应用程序错误,远程查看(出于安全原因)的细节。它可以,但是,可以通过在本地服务器计算机上运行的浏览器查看。详细信息:若要使此特定错误信息的细节是对远程计算机上查看,请创建<&的customErrors GT;在位于当前Web应用程序根目录下的web.config配置文件中的标签。该<&的customErrors GT;那么标签应该有它的mode属性设置为Off。<! - web.config配置文件 - ><结构>
    <&的System.Web GT;
        <的customErrors模式=关/>
    < /system.web>
< /结构>
注意:你所看到的当前错误页可以用自定义错误页替换通过修改应用程序的&LT的defaultRedirect属性;&的customErrors GT;配置标记以指向自定义错误页的URL。<! - web.config配置文件 - ><结构>
    <&的System.Web GT;
        <的customErrors模式=仅限远程的defaultRedirect =mycustompage.htm/>
    < /system.web>
< /结构>


解决方案

我是pretty确保app_offline.htm在ASP.NET中的保留文件名,将永远如果present送达服务器上

尝试重命名它error.htm和更新您的<的customErrors /方式> 块匹配

For some reason, when I get an ASP.NET runtime error, it's not loading my custom error page

<customErrors mode="On" defaultRedirect="app_offline.htm" redirectMode="ResponseRewrite">
    <error statusCode="404" redirect="app_offline.htm"/>
        <error statusCode="500" redirect="app_offline.htm"/>
</customErrors>

That's in my web.config.

I'm still getting this though and it's not loading my error .htm page:

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

解决方案

I'm pretty sure that app_offline.htm is a reserved filename in ASP.NET that will always be served if present on the server.

Try renaming it to error.htm and updating your <customErrors /> block to match.

这篇关于自定义错误页不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆