4

I have a .NET 4.0 application on IIS 7 that contains a nested .NET 2.0 application. The problem is that the the nested .NET 2.0 application has the system.web.extensions sectionGroup within the <configSections> of the web.config and the .NET 4.0 parent applications machine.config contains those sectionsGroups as well. This causes status code 500 server error.

Commenting out the system.web.extensions sectionGroup from the child applications web.config works but isn't an option with our setup.

How can I prevent inheriting the parent web.config in the child application? I've seen that <location path="." inheritInChildApplications="false"> was used in previous .NET versions but what do I wrap the location element around?

Intellisense shows me that "The inheritInChildApplications attribute is not allowed" and it doesn't appear to matter where I put it.

Jason Eades
  • 1,547
  • 5
  • 16
  • 31

2 Answers2

6

We wrap all of the settings that we don't want inherited in an empty location element:

<location inheritInChildApplications="false">

Intellisense complains about it, but it seems to run just fine in production mode.

There is some good additional information in this article.

competent_tech
  • 44,465
  • 11
  • 90
  • 113
  • 1
    I tried wrapping the configSection located @ Windows\Microsoft.NET\Framework\v4.0.30319\Config in a location element and the nested application still returns 500 server error. Was this the wrong spot? The only section I want to prevent inheritance on is the configSection. – Jason Eades Aug 03 '12 at 19:57
  • In other words, I don't think the or the section will handle being wrapped in the location element. – Jason Eades Aug 03 '12 at 20:37
  • 1
    Ah, unfortunately I don't think that will work (hadn't realized that you were having issues with the config sections). Can you modify the inner app's config? – competent_tech Aug 03 '12 at 20:39
  • Yes I can. Which leads me to believe the best solution is using '' for that section in the child config. Unfortunately, I had real trouble doing web.config replacements on the configSection (which is another issue entirely). Without expanding this question too much, I will only need the '' section during my staging build. It won't be nested in production or dev. – Jason Eades Aug 03 '12 at 20:53
0

The solution in this case was to modify my test environment to avoid the configSection conflicts. There doesn't appear to be a real solution for this conflict. See here: How to stop inheritance of configSections in Web Config

Community
  • 1
  • 1
Jason Eades
  • 1,547
  • 5
  • 16
  • 31