Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Remove Web.Config Nodes using Transform

I have a web.config containing rewrite rules like this:

<system.webServer>
    <rewrite>
      <rules><!-- Some rules here --></rules>
    </rewrite>
</system.webServer>

For a particular deployment configuration, I want to remove the <rewrite> node entirely.

I tried doing this:

<system.web>
    <rewrite xdt:Transform="RemoveAll" />
</system.web>    

Based on this documentation:

http://msdn.microsoft.com/en-us/library/dd465326.aspx

but the <rewrite> node remains.

What am I missing?

like image 922
Eric J. Avatar asked Apr 30 '12 18:04

Eric J.


1 Answers

Hmm I just tried this here is my transform file.

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <system.webServer>
    <rewrite xdt:Transform="RemoveAll" />
  </system.webServer>

</configuration>

And here is the result: illustrates difference of web.config after transform FYI preview provided by SlowCheetah.

I also packaged the web project and verified that the web.config indeed did not have the rewrite node. One thing to try here is to delete your obj\ folder and try again. Can you let me know the results?

like image 55
Sayed Ibrahim Hashimi Avatar answered Nov 19 '22 05:11

Sayed Ibrahim Hashimi