8

We have a large content management system configured as the main site in IIS. We also have a handful of independent applications that are configured as applications under IIS 7.5. The issue that we’re running into is that the child applications are inheriting the web.config file from the parent application even though they are completely independent applications and share next to no configuration settings. Ideally, we’d like to stop the child applications from inheriting the web.config file at all. Is that possible?

If not, we’d like to tell the child applications not to inherit parts of the master web.config file. We’ve tried editing the child web.config files and adding directives to the configuration file, but that doesn’t seem to be working.

I understand that we can modify the parent web.config file to add in directives to effectively restrict the inheritance; however we’re hesitant to do this because we’re not sure how that will impact the CMS. The web.config file in question is also about 1000 lines long and we’re not sure how many changed we’d need to make. We can, of course, move forward with this solution and test thoroughly, but I’d rather find one that doesn’t require modifying the parent application.

We’ve also tried updating the child web.config files to manually remove certain elements of the parent web.config and we’ve had mixed results. We can unload HTTP handlers and things like that, but we can’t seem to unload any of the references to the App_Code folder.

In short, is it possible to have a child application NOT inherit any part of the web.config file? If not, is it possible to overwrite or otherwise force the child to ignore settings in the parent web.config file?

Thanks

Dave

Dave Mroz
  • 1,509
  • 2
  • 14
  • 27
  • Can you give more information about your reference to the App_Code folder? What section is it in? Best if you can just include that snippet in your question so we can see. – Jon Galloway Dec 17 '11 at 21:59

3 Answers3

11

In addition to using <clear/> or overwriting the settings in the child web.config, you can use the inheritInChildApplications setting in conjunction with in the parent web.config.

Example:

<location path="." inheritInChildApplications="false"> 
  <system.web>     
    <!-- ... -->
  </system.web>
</location>

You can wrap the location around the entire <system.web> or just around specific sections.

Some links for more info:

Community
  • 1
  • 1
Jon Galloway
  • 52,327
  • 25
  • 125
  • 193
1

This is a bit of a workaround, but what we do for polygot apps is to reverse proxy anything that can't live under the parent's web.config. Lot easier than fighting it in most cases.

Now, this intranet app sounds like it might be using windows auth, if so that won't work as you can't reverse proxy windows authentication.

Wyatt Barnett
  • 15,573
  • 3
  • 34
  • 53
0

Add <clear/> at the beginning of a section to get rid of inherited settings.

pdubs
  • 2,698
  • 1
  • 16
  • 15
  • Some of the message was stripped out of my original post. It was supposed to say "We've tried editing the child web.config files and adding `` directives to the configuration file, but that doesn’t seem to be working." and "I understand that we can modify the parent web.config file to add in `` directives to effectively restrict the inheritance; however..." – Dave Mroz Dec 16 '11 at 15:15
  • 1
    Where did you add ``? AFAIK it needs to be under each section you want to clear. Putting it under `` or `` would work; putting it under `` or `` does _not_. – pdubs Dec 16 '11 at 15:26
  • I tried both approaches. The `` seems to work for unloading things such as the HTTP handlers, but we have this pesky call to the App_Code folder in the parent web.config and the `` isn't working for that section. – Dave Mroz Dec 16 '11 at 15:30
  • I believe ``, ``, and `` are the only directives available for addressing inheritance, so `` is your only option unless you move the site out of the subdirectory and run it as a separate application. You could fake a subdirectory by using an ISAPI filter. – pdubs Dec 16 '11 at 15:59