Question

I am trying to add a set of URL Rewriting rules but only to the published version of the web site I'm developing.

I find all sorts of examples if i want to change say the connection string value, but I cannot find an example of how to add something that does ot already exists in the main web.config.

What I need is to add the rewrite node under the system.WebServer.

Was it helpful?

Solution

All you need is to use xdt:Transform="Insert" attribute within a tag that you want added during transformation. Read more about it here: http://msdn.microsoft.com/en-us/library/dd465326.aspx

You can take the below sample as a starting point (which is my Web.Release.config file):

<?xml version="1.0"?>

<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <!-- Enable static content caching in release mode -->
    <system.webServer xdt:Transform="Insert">
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="5.00:00:00" cacheControlCustom="public" />
        </staticContent>
    </system.webServer>
</configuration>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top