I have an asp.net application, which must run under SSL, and it has some rewrite rules defined in web.config to accomplish this.
<!--file web.config -->
....
</system.webServer>
<rewrite>
<rules configSource="webrewrite.config" />
</rewrite>
</system.webServer>
<!--file web.config -->
<rules>
....
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
....
</rules>
However, in development mode (with local web server or IIS Express) I don't want to use SSL. So I would like to be able to use web.config transformations to remove one or more rewrite rules (but not all)
The xdt:Transform attribute value "SetAttributes" indicates that the purpose of this transform is to change attribute values of an existing element in the Web. config file.
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).
If you want to remove the Entire Section for your Dev Configuration use
<system.webServer>
<rewrite xdt:Transform="Remove" >
</rewrite>
</system.webServer>
I solved the problem, by using Remove transform, as shown below
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
....
<system.webServer>
<rewrite>
<rules>
<rule name="RulaNameToRemove"
xdt:Transform="Remove"
xdt:Locator="Match(name)" >
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
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