【问题标题】:No element in the source document matches /configuration/system.web/authorization/源文档中没有元素匹配 /configuration/system.web/authorization/
【发布时间】:2017-03-13 13:57:33
【问题描述】:

我在转换我的 Web.Config 时遇到了下一个问题:

源文档中没有元素匹配 '/configuration/system.web/authorization/allow[@roles='WhateverGroupNameRenamedForProd']'

这是我的 Web.Config:

 <system.web>
<compilation targetFramework="4.5.2" debug="true" />
<httpRuntime targetFramework="4.5" />
<authorization>
  <allow roles="WhateverGroupName" />
  <deny users="*" />
</authorization>

还有 Web.Production.Config:

<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<authorization>
  <allow roles="WhateverGroupNameRenamedForProd" xdt:Transform="SetAttributes" xdt:Locator="Match(roles)"/>
</authorization>

我做错了什么?在此先感谢:)

【问题讨论】:

    标签: web-config authorization roles web.config-transform


    【解决方案1】:

    对于那些已经感兴趣的人,我发现并解决了问题:它基本上是在 SetAttributes 上:

    我的旧代码:

    <allow roles="WhateverGroupNameRenamedForProd" xdt:Transform="SetAttributes" xdt:Locator="Match(roles)"/>
    

    应替换为:

    <allow roles="WhateverGroupNameRenamedForProd" xdt:Transform="SetAttributes(roles)"/>
    

    那么您已经在 SetAttributes 上指定了属性名称,在我的例子中是“角色”。

    【讨论】:

    • 您必须了解xdt:Locator=Match(roles) 的含义以及为什么它不起作用:在源文件中查找具有指定角色值的元素(即WhateverGroupNameRenamedForProd),然后进行转换 (SetAttributes)。由于源文件中的 &lt;allow 元素的角色值为 WhatevetGroupName,因此不匹配。
    猜你喜欢
    • 1970-01-01
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 2011-12-28
    • 1970-01-01
    • 2014-03-28
    • 2020-08-24
    • 1970-01-01
    相关资源
    最近更新 更多