如何在服务器抛出“/'应用程序中的服务器错误”时查看特定的错误信息. (ASP.NET)

本文关键字:错误 服务器 信息 NET ASP 应用程序 | 更新日期: 2023-09-27 18:36:48

我的一个网页上收到运行时错误。

该错误告诉我在 web.config 文件中设置customErrors mode="Off",这没有区别。(我假设服务器配置为不抛出特定错误)

我的配置文件看起来像这样。

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

它在本地运行良好。有没有办法让我确切地看到导致错误的原因?

如何在服务器抛出“/'应用程序中的服务器错误”时查看特定的错误信息. (ASP.NET)

尝试在 Web.config 文件中添加以下内容。启用详细错误模式可能会提供有关错误的详细信息。

<configuration>
     <system.webServer>
        <httpErrors errorMode="Detailed" />
        <asp scriptErrorSentToBrowser="true"/>
     </system.webServer>
     <system.web>
        <customErrors mode="Off"/>
         <compilation debug="true"/>
     </system.web>
 </configuration>

这适用于 IIS 7。如果您使用的是 IIS 6,请忽略 system.webServer 标记。

可能需要

配置 IIS 以启用详细的错误报告。 不建议用于生产计算机,因此,如果必须使用它,请确保在完成后将其关闭。 请参阅 http://blogs.msdn.com/b/rakkimk/archive/2007/05/25/iis7-how-to-enable-the-detailed-error-messages-for-the-website-while-browsed-from-for-the-client-browsers.aspx