We use security trimming in our web app, so nodes like the following are necessary:
<location path="admin/employees" xdt:Transform="Replace" xdt:Locator="Match(path)">
<system.web>
<authorization>
<allow roles="domain\role1,domain\开发者_StackOverflow社区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>
Notice that we also do transformation. Since the roles vary from the various environments we have (dev, staging, and production), it's quite tedious to implement transformation across all three configurations.
What I would like to do is encapsulate all location nodes into a parent node, perhaps called <locations>
. That way, I could implement transformation on the locations node instead each location node like this:
<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>
Is this possible?
Unless you want to write some custom bits to run after a deploy, you are stuck with the MS Build transform. Yes, it is a bit tedious to have to set up each environment, but that is the nature of beast right now.
I have use Nant in the past to build and conquer some of the transformation issues. A bit less tedious, for some, but still tedious.
I wish I had a better story for you.
Since you are using locations, you can also set up the common bits in folders and set up a specific web.config. Still tedious, but might be less of a pain than a single web.config file at root.
精彩评论