I'm trying to add a location authorization in a web.config transform, but the only way I've found that works, is with the SetAttributes(path) attribute, but this seems to be creating an instance of the location for each child item:
<location path="AjaxFileUploadHandler.axd" xdt:Transform="SetAttributes(path)">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
Produces a web.config that includes:
<location path="AjaxFileUploadHandler.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="AjaxFileUploadHandler.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="AjaxFileUploadHandler.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="AjaxFileUploadHandler.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="AjaxFileUploadHandler.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
How can I get it to add just one of these, not 5??
If you are adding a location item the web.config which has no location sections by default, then you need to use InsertAfter or InsertBefore transformation. The code below would insert new Location section into web.config after /configuration/system.web path.
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="AjaxFileUploadHandler.axd" xdt:Transform="InsertAfter(/configuration/system.web)">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>