Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config inheritance: <clear/> causes XML Parsing Error in <system.webServer><modules>

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.

Parent web.config

...
<system.webServer>
  ...
  <modules>
    <add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core" />
    <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core" />
    ...
  </modules>
...

I can't use the following location tag in the root because there are other sub folders where I do want to inherit. Is there any way for the child to turn off inheritance from the parent?

<location path="." inheritInChildApplication="false"> 

Child web.config

...
<system.webServer>
  ...
  <modules>
    <clear/>
  </modules>
...

I tried using clear but this results in a strange parsing error: "XML Parsing Error: no element found Location:... Line Number 1, Column 1:"

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?

like image 573
Ben Schipper Avatar asked Nov 14 '22 10:11

Ben Schipper


1 Answers

It sounds to me like the simplest solution is to set your application up as it's own application since the subfolder contains, as you refer to it, an application. You can still link users back to your other parent app. Just set the subfolder to do a redirect of all requests to the other application. It sounds more like an architectural issue to me but I am only guessing based on the small amount of information.

The other option is that if your parent app is referencing an assembly in web.config, exclude it in the child app.

My last suggestion would be that you may just need to split the source code and references of the apps up a little better and re-compile.

like image 102
GolfARama Avatar answered Dec 19 '22 02:12

GolfARama