In my Web.Config I have the following
<system.webServer>
<modules>
**some code**
</modules>
<handlers>
**some code**
</handlers>
</system.webServer>
How do I transform it so I can inject a new sub section for "security" into "system.webServer"? Everything I have tried and search on so far has failed.
What I desire is shown below:
<system.webServer>
<modules>
**some code**
</modules>
<handlers>
**some code**
</handlers>
<security>
<ipSecurity allowUnlisted="false" denyAction="NotFound">
<add allowed="true" ipAddress="10.148.176.10" />
</ipSecurity>
</security>
</system.webServer>
If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).
A transform file is an XML file that specifies how the Web. config file should be changed when it is deployed. Transformation actions are specified by using XML attributes that are defined in the XML-Document-Transform namespace, which is mapped to the xdt prefix.
A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.
Found the solution that worked. Within my Web.Azure.Config file I had to add the following:
<system.webServer>
<security xdt:Transform="Insert">
<ipSecurity allowUnlisted="false" denyAction="NotFound">
<add allowed="true" ipAddress="10.148.176.10" />
</ipSecurity>
</security>
</system.webServer>
I tried this before posting the question but due to a typo in another part of Web.Config it was erroring.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With