即使使用 customErrors=“Off”,Web.config 也不会远程显示错误。 (在 ubuntu/mono 上)

发布于 2024-10-18 08:08:08 字数 3184 浏览 6 评论 0原文

这是我的 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>

Here is my Web.config file:

<?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>

Even with customErrors mode set to Off (and its definitely a capital "O") its still showing me the default errors page telling me to set this property before I can see that actual error remotely.

I don't have a machine.config file, and I've also set this customErrors mode="Off" in the Web.Debug.config and the Web.Release.config.

Any ideas anyone?

Thank you very much.

Edit - what its showing:

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

不必你懂 2024-10-25 08:08:08

您的代码中的行

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

是错误的。这里更正:(见最后一个引号)

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

The Line

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

in your code is wrong. Here the correction: (see the last quotation mark)

<compilation debug="true" strict="false" explicit="true" />
つ低調成傷 2024-10-25 08:08:08

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

I found that I actually had to restart apache after making changes to the web.config file...

转身泪倾城 2024-10-25 08:08:08

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

Couldn't find an answer - we had to get Windows based hosting.

音盲 2024-10-25 08:08:08

这些设置对我来说看起来是正确的。

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

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

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

Those settings look correct to me.

Are you positive you're looking at the right web.config file? Are you overriding any of these values in your page directive(s)?

Consider posting your whole web.config (sans private info).

EDIT: Also, what is it showing when you view the page?

十二 2024-10-25 08:08:08

尽管在过去的两天里我对 Mono 感到非常沮丧,并考虑自己获得 Windows 托管,但我发现至少对于 MVC 4 网站来说,为了获得详细的错误,您必须进入 Views 并在那里找到 Web.config 并添加所需的指令

将其添加到主目录中的 Web.config 中不会改变任何事情。

然后真正的麻烦就开始了。

Although I am getting really frustrated with Mono over the past 2 days and considering myself getting windows hosting I found out that at least for MVC 4 web sites in order to get detailed errors you have to go in Views and find the Web.config there and add the required directive <customErrors mode="Off"/>.

Adding it in the Web.config found in the main directory does not change a thing.

Then the real trouble begins.

爱你是孤单的心事 2024-10-25 08:08:08

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

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

  • chmod -R ugo+rwx /your_site_root

但不建议使用此类权限进入生产环境。

I did have the some problem. I am also pretty new to linux. In my case, the problem was that I have not added the required permissions to the site folder and a result, the Web.config was not even read.

Just for debug, you could try allow full permissions for all to the entire site folder (recursively).

  • chmod -R ugo+rwx /your_site_root

It is not recommended though to go to production with such permissions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文