【问题标题】:Why can't i see a detailed error message in this aspx page?为什么我在这个 aspx 页面中看不到详细的错误信息?
【发布时间】:2011-03-25 18:05:33
【问题描述】:

我有一个aspx page,它显示自定义错误,但我看不到详细的错误消息。 我的 web.config 看起来像这样,

<?xml version="1.0"?>
    <configuration>
    <appSettings />
    <connectionStrings />
    <system.web>
        <compilation debug="true" />
        <authentication mode="Windows" />
        <customErrors mode="On" />
    </system.web>
</configuration>

【问题讨论】:

    标签: asp.net runtime-error custom-errors


    【解决方案1】:

    要查看你需要customErrors 关闭的错误,像这样:

    <customErrors mode="Off"></customErrors>
    

    From the docs,这里是mode属性的选项:

    • On - 指定启用自定义错误。如果未指定 defaultRedirect 属性,用户会看到一般错误。自定义错误会显示给远程客户端和本地主机。
    • 关闭 - 指定禁用自定义错误。详细的 ASP.NET 错误会显示给远程客户端和本地主机。
    • RemoteOnly - 指定仅向远程客户端显示自定义错误,并向本地主机显示 ASP.NET 错误。这是默认值。

    警告

    在现场制作网站上设置 Off 风险很大,因为某些错误消息可能会危及您网站上的敏感数据(例如代码和路径,甚至可能是密码)。

    【讨论】:

    • 我认为“关闭”是危险的设置。 CustomErrors off 允许默认错误及其堆栈跟踪通过。
    • @JohnMelville 你是对的 - 编辑不正确,我已经更新了 - 谢谢!
    猜你喜欢
    • 2018-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-22
    • 2011-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多