【问题标题】:Unrecognized element 'remove' web.config无法识别的元素“删除”web.config
【发布时间】:2020-07-08 14:01:04
【问题描述】:

我正在尝试在 Umbraco CMS 中删除 Member Groups,但收到 500 错误。当我检查事件日志时,我得到了这个错误

Exception message: Unrecognized element 'remove'. (C:\inetpub\wwwroot\fakesite.com\web.config line 155)

我不确定这是什么,但我已经从cmsMember2MemberGroup 删除了所有记录,所以我确定没有成员在使用它。但不知何故,它抛出了一个错误。我在 web.config 文件中缺少一些配置吗?如果是这样,我应该添加什么......好吧,我总是可以删除他们在数据库中的条目,但我不想这样做。有没有办法解决这个问题?

更新:

这是第 155 行的内容:

<system.web>
    <trust level="Full" />
        <customErrors allowNestedErrors="true" defaultRedirect="https://www.fakesite.com/page-not-found/" mode="On">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" redirect="https://www.fakesite.com/page-not-found/"/>
        </customErrors>

【问题讨论】:

  • 请向我们展示该配置文件的第 155 行。
  • @mjwills 更新了我的问题

标签: c# .net umbraco umbraco7


【解决方案1】:

很抱歉将其发布为答案,但我没有足够的业力发表评论。

我在黑暗中拍摄,但没有删除应该通过CustomErrorCollection.Remove(String) 以编程方式添加的元素?这是我从MSDN 那里得到的。

The Remove method inserts a remove element into the customErrors section of the configuration file at the current hierarchy level. This removes the reference to the add element defined in the parent configuration files at higher levels in the hierarchy.

【讨论】:

  • 感谢您的链接。我不知道为什么,但它只会影响 Live 应用程序,但托管在 Azure 中的 Staging 应用程序不会引发此类错误
【解决方案2】:

我不确定在自定义错误中使用 remove 是否有意义。 Umbraco 的所有示例似乎只在 HTTP 错误中使用 remove

<configuration>
    <system.web>
        <customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/500.aspx">
            <error statusCode="404" redirect="~/404.aspx"/>
            <error statusCode="500" redirect="~/500.aspx"/>
        </customErrors>
    </system.web>
    <system.webServer>
        <httpErrors errorMode="Custom">
            <remove statusCode="404"/>
            <error statusCode="404" path="404.html" responseMode="File"/>
            <remove statusCode="500"/>
            <error statusCode="500" path="500.html" responseMode="File"/>
        </httpErrors>
    </system.webServer>
</configuration>

【讨论】:

    猜你喜欢
    • 2011-02-11
    • 2012-10-20
    • 2010-11-13
    • 2013-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多