【问题标题】:Web.config isn't showing errors remotely even with customErrors="Off" (on ubuntu/mono)即使使用 customErrors="Off"(在 ubuntu/mono 上),Web.config 也不会远程显示错误
【发布时间】:2011-06-29 22:10:37
【问题描述】:

这是我的 Web.config 文件:

<?xml version="1.0"?>
<configuration>
    <system.web>
        <customErrors mode="Off" />    
        <compilation debug="true" strict="false" explicit="true />    
        <pages>
          <namespaces>
            <clear />
            <add namespace="System" />
            <add namespace="System.Collections" />
            <add namespace="System.Collections.Generic" />
            <add namespace="System.Collections.Specialized" />
            <add namespace="System.Configuration" />
            <add namespace="System.Text" />
            <add namespace="System.Text.RegularExpressions" />
            <add namespace="System.Web" />
            <add namespace="System.Web.Caching" />
            <add namespace="System.Web.SessionState" />
            <add namespace="System.Web.Security" />
            <add namespace="System.Web.Profile" />
            <add namespace="System.Web.UI" />
            <add namespace="System.Web.UI.WebControls" />
            <add namespace="System.Web.UI.WebControls.WebParts" />
            <add namespace="System.Web.UI.HtmlControls" />
          </namespaces>
          <controls>
            <add src ="~/controls/maleBed.ascx" tagPrefix ="mycontrol" tagName ="male"/>
            <add src ="~/controls/femaleBed.ascx" tagPrefix ="mycontrol" tagName ="female"/>
          </controls>
        </pages>
    </system.web>
</configuration>

即使将 customErrors 模式设置为 Off(并且它肯定是大写的“O”),它仍然向我显示默认错误页面,告诉我在远程看到实际错误之前设置此属性。

我没有 machine.config 文件,我还在 Web.Debug.config 和 Web.Release.config 中设置了这个 customErrors mode="Off"。

有什么想法吗?

非常感谢。

编辑 - 显示内容:

Server Error in '/' Application

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>

【问题讨论】:

  • 你有想过这个吗?
  • 不...我们必须获得 Windows 专用主机。

标签: asp.net mono web-config custom-errors


【解决方案1】:

线

<compilation debug="true" strict="false" explicit="true />

在您的代码中是错误的。这里更正:(见最后一个引号)

<compilation debug="true" strict="false" explicit="true" />

【讨论】:

    【解决方案2】:

    我发现我在更改 web.config 文件后实际上必须重新启动 apache...

    【讨论】:

    • 只需重新加载就足够了。
    【解决方案3】:

    找不到答案 - 我们必须获得基于 Windows 的主机。

    【讨论】:

      【解决方案4】:

      这些设置在我看来是正确的。

      您确定您正在查看正确的 web.config 文件吗?您是否在页面指令中覆盖了这些值中的任何一个?

      考虑发布您的整个 web.config(没有私人信息)。

      编辑:另外,当您查看页面时显示的是什么?

      【讨论】:

      • 那是我的整个 web.config 文件...:/它看起来对我来说也是正确的。我会看看,但我认为我不会在任何地方覆盖它们
      • 我没想法了,伙计……可能是个怪癖。可能值得重新启动服务。
      【解决方案5】:

      尽管在过去 2 天里我对 Mono 感到非常沮丧,并考虑自己获得 Windows 托管,但我发现至少对于 MVC 4 网站,为了获得详细的错误,你必须进入 Views 并找到Web.config 那里并添加所需的指令&lt;customErrors mode="Off"/&gt;

      在主目录中的 Web.config 中添加它并不会改变任何事情。

      那么真正的麻烦就开始了。

      【讨论】:

        【解决方案6】:

        我确实遇到了一些问题。我对linux也很陌生。就我而言,问题是我没有向站点文件夹添加所需的权限,结果甚至没有读取 Web.config。

        仅出于调试目的,您可以尝试允许所有人对整个站点文件夹的完全权限(递归)。

        • chmod -R ugo+rwx /your_site_root

        不建议使用此类权限进行生产。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-07-08
          • 2016-12-15
          • 2012-04-09
          • 2019-12-28
          • 2019-12-14
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多