为什么我在这个aspx页面中看不到详细的错误消息?

时间:2022-10-07 09:47:34

I have a aspx page and it displays custom error but i can't see a detailed error message. My web.config looks like this,

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

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

1 个解决方案

#1


15  

To see the error you need customErrors off, like this:

要查看错误,您需要关闭customErrors,如下所示:

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

From the docs, here are the options for the mode attribute:

从文档中,以下是mode属性的选项:

  • On - Specifies that custom errors are enabled. If no defaultRedirect attribute is specified, users see a generic error. The custom errors are shown to the remote clients and to the local host.
  • 开 - 指定启用自定义错误。如果未指定defaultRedirect属性,则用户会看到一般错误。自定义错误显示给远程客户端和本地主机。

  • Off - Specifies that custom errors are disabled. The detailed ASP.NET errors are shown to the remote clients and to the local host.
  • 关 - 指定禁用自定义错误。详细的ASP.NET错误将显示给远程客户端和本地主机。

  • RemoteOnly - Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host. This is the default value.
  • RemoteOnly - 指定仅向远程客户端显示自定义错误,并向本地主机显示ASP.NET错误。这是默认值。

Warning

Setting Off on a live-production site is very risky as some error messages might compromise sensitive data on your site (like code and paths maybe even passwords).

在实时生产站点上设置关闭是非常危险的,因为某些错误消息可能会危害您站点上的敏感数据(例如代码和路径甚至密码)。

#1


15  

To see the error you need customErrors off, like this:

要查看错误,您需要关闭customErrors,如下所示:

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

From the docs, here are the options for the mode attribute:

从文档中,以下是mode属性的选项:

  • On - Specifies that custom errors are enabled. If no defaultRedirect attribute is specified, users see a generic error. The custom errors are shown to the remote clients and to the local host.
  • 开 - 指定启用自定义错误。如果未指定defaultRedirect属性,则用户会看到一般错误。自定义错误显示给远程客户端和本地主机。

  • Off - Specifies that custom errors are disabled. The detailed ASP.NET errors are shown to the remote clients and to the local host.
  • 关 - 指定禁用自定义错误。详细的ASP.NET错误将显示给远程客户端和本地主机。

  • RemoteOnly - Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host. This is the default value.
  • RemoteOnly - 指定仅向远程客户端显示自定义错误,并向本地主机显示ASP.NET错误。这是默认值。

Warning

Setting Off on a live-production site is very risky as some error messages might compromise sensitive data on your site (like code and paths maybe even passwords).

在实时生产站点上设置关闭是非常危险的,因为某些错误消息可能会危害您站点上的敏感数据(例如代码和路径甚至密码)。