源文档中没有与 /configuration/system.web/authorization/ 匹配的元素

Car*_*los 7 authorization web-config roles web.config-transform

转换我的 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>
Run Code Online (Sandbox Code Playgroud)

Web.Production.Config:

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

我做错了什么?提前致谢 :)

Car*_*los 7

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

我的旧代码:

<allow roles="WhateverGroupNameRenamedForProd" xdt:Transform="SetAttributes" xdt:Locator="Match(roles)"/>
Run Code Online (Sandbox Code Playgroud)

应改为:

<allow roles="WhateverGroupNameRenamedForProd" xdt:Transform="SetAttributes(roles)"/>
Run Code Online (Sandbox Code Playgroud)

然后你在SetAttributes上指定了属性名称,在我的例子中它是“角色”。