No element in the source document matches /configuration/system.web/authorization/

*爱你&永不变心* 提交于 2019-12-10 18:21:31

问题


I have the next issue when transforming my Web.Config:

No element in the source document matches '/configuration/system.web/authorization/allow[@roles='WhateverGroupNameRenamedForProd']'

Here my Web.Config:

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

And the Web.Production.Config:

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

What I'm doing wrong? Thanks in advance :)


回答1:


For the ones already interested, I found and fixed the problem: It was basically on the SetAttributes:

My old code:

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

Should be replaced by:

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

Then you have so specify the attribute name on the SetAttributes, in my case it was "roles".



来源:https://stackoverflow.com/questions/40342950/no-element-in-the-source-document-matches-configuration-system-web-authorizatio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!