title: web.config inheritance: <clear/> causes XML Parsing Error in <system.webServer><modules>
body: <p>I am trying to add a small asp.net application to a sub folder of my existing website.  The issue is that the root web.config file contains modules that break my application.  I want to prevent/remove the Web.config inheritance.</p>
  
  <p>Parent web.config</p>
  
  <pre><code>...
  &lt;system.webServer&gt;
    ...
    &lt;modules&gt;
      &lt;add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core" /&gt;
      &lt;add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core" /&gt;
      ...
    &lt;/modules&gt;
  ...
  </code></pre>
  
  <p>I can't use the following location tag in the root because there are other sub folders where I <strong>do</strong> want to inherit. Is there any way for the child to turn off inheritance from the parent?</p>
  
  <pre><code>&lt;location path="." inheritInChildApplication="false"&gt; 
  </code></pre>
  
  <p>Child web.config</p>
  
  <pre><code>...
  &lt;system.webServer&gt;
    ...
    &lt;modules&gt;
      &lt;clear/&gt;
    &lt;/modules&gt;
  ...
  </code></pre>
  
  <p>I tried using clear but this results in a strange parsing error:
  "XML Parsing Error: no element found Location:... Line Number 1, Column 1:"</p>
  
  <p>If I use remove for each module I have some success. As long as I leave at least 1 module. (Doesn't matter which one) When I remove the last module I get the same parsing error as the clear.  Anyone have any idea why this error is happening?  Is there any other way to eliminate web.config inheritance?</p>