Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unloading parts of a web.config file from a child application

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

like image 782
Dave Mroz Avatar asked Dec 16 '11 15:12

Dave Mroz


People also ask

Can a one web application project can contain more than one Web config file?

Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration.

How do I stop web config inheritance?

The Web. Config settings are inherited automatically from the root application, and it may raise a problem to run the Dashboard Service at IIS. To overcome this, use the location tag with path value as '. ' and inheritInChildApplications as 'false' in the Web.

What is the web config file used for in MVC web application development?

The web. config file is required at the root of the app to enable the publishing of multiple apps using Web Deploy.

What is the role of web config file in web application?

A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).


2 Answers

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:

  • inheritInChildApplications on MSDN (read the community content at the bottom for more)
  • StackOverflow: Avoid web.config inheritance in child web application using inheritInChildApplications
  • Blog post: Stopping web.config inheritance
like image 140
Jon Galloway Avatar answered Oct 09 '22 04:10

Jon Galloway


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.

like image 28
Wyatt Barnett Avatar answered Oct 09 '22 06:10

Wyatt Barnett