0
我們使用的安全性在我們的Web應用程序微調,所以像下面的節點是必要的:我的ASP.NET web.config中的自定義XML節點/標記?
<location path="admin/employees" xdt:Transform="Replace" xdt:Locator="Match(path)">
<system.web>
<authorization>
<allow roles="domain\role1,domain\role2"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="admin/whatever" xdt:Transform="Replace" xdt:Locator="Match(path)">
<system.web>
<authorization>
<allow roles="domain\role1,domain\role2"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
請注意,我們也做改造。由於角色因我們所擁有的各種環境(開發,暫存和生產)而異,因此在所有三種配置中實施轉換非常繁瑣。
我想要做的就是將所有的位置節點封裝到一個父節點中,也許稱爲<locations>
。這樣,我可以在位置節點上實現轉換,而不是像下面這樣的每個位置節點:
<locations xdt:Transform="Replace">
<location path="admin/employees">
<system.web>
<authorization>
<allow roles="domain\role1,domain\role2"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="admin/whatever">
<system.web>
<authorization>
<allow roles="domain\role1,domain\role2"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
</locations>
這可能嗎?