【问题标题】:How can I get my web.config file to show errors remotely?如何让我的 web.config 文件远程显示错误?
【发布时间】:2013-01-08 02:45:18
【问题描述】:

我正在尝试查看我的网站的错误,当我访问该网站时,我收到以下消息:

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>

所以我所做的是在其中创建一个 web.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
     <customErrors mode="Off"/>
  </system.web>
</configuration>

但对我来说可悲的是,这真的让杰克变得与众不同。我在这里做错了什么?

【问题讨论】:

    标签: asp.net web-config


    【解决方案1】:

    试试这个: CustomErrors mode="Off"

    顺便说一句,asp net项目模板包含web.config文件(它应该在你项目的根文件夹中),所以你不必手动创建它。可能你已经创建了另一个?

    【讨论】:

      【解决方案2】:

      如果您在本地而不是远程看到错误,请尝试将其添加到 web.config;

      <system.webServer>
          <httpErrors errorMode="Detailed" />
      </system.webServer>
      

      这是 IIS 的一项功能,可向外部用户隐藏可能损害您网站的内部工作,因此它没有默认设置是有原因的。

      【讨论】:

      • 我们还需要在 &lt;system.web&gt; 中添加 &lt;customErrors mode="Off" /&gt; 才能使其正常工作。
      【解决方案3】:

      可能不是 IIS!

      我在此页面上尝试了这两种解决方案,以及更多。他们都没有解决我们的问题,但它们是值得检查的好东西,会引起问题。所以先检查一下。如果你还在纠结,并且正在使用 PHP,请检查你的 PHP 设置。

      为我解决的问题是编辑我们的 php.ini 文件并指定:

      display_errors: On
      

      我也设置了:

      display_startup_errors: On
      

      只是为了衡量。

      这解决了问题,我们真正的问题原来是在开发到阶段迁移期间遗漏了一个被忽视的逗号。

      【讨论】:

      • 这与 ASP 无关... PHP != ASP
      • 谁说过 ASP?问题是关于 web.config,即使没有 ASP,也会使用它。事实上,这就是 FastCGI。请注意添加 asp 的标签,但问题不是特定于 asp 的。坏标签一直在发生。
      • Ummmm.... OP 做了... 假设是你能做的最糟糕的事情。只有在与问题共享正确内容时才能正确给出答案。
      • OP添加了一个标签,上面写着asp.net,是的,但是他的问题没有具体提到ASP。事实上,只用 PHP 和根本没有 asp.net 代码来复制他的确切配置和他的确切错误消息是微不足道的。
      • 此外,我确实提到了“如果...您使用的是 PHP,”...
      猜你喜欢
      • 2012-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-29
      • 2012-06-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多