How do I stop web.config inheritance

Ok

I have a Asp .net 3.5 Website in IIS6 on Windows Server 2003 (32bit).

with a Asp.Net 1.1 WebApplication in a sub virtual directory. (this is set to use the older 1.1 .net runtime and is configured with it’s own App Pool. So for all intents and purposes is completely seperate.

Except it keeps on inheriting the root website’s .net 3.5 web.config.

I’ve tried adding

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

to the root websites web.config but it doesn’t seem to work.

Strangely the error is actually

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

which is being reported from the .net 1.1 runtime with the website path WEBSITE/OLD_WEBAPP but it’s moaning about the webSite (as in the .net 3.5 one’s) web.config and how it doesn’t understand the type attribute on the sectionGroup tag.

What am I doing wrong? Please tell me it’s something obvious. Thanks

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

Method 2

Just to let everyone know, I’ve found an answer that serves my purposes for now.

I ended up putting all the configuration in the .net 2.0 global web.config

C:WINDOWSMicrosoft.NETFrameworkv2.0.50727CONFIG

I got this suggestion from this comment on connect.microsoft.com

The configuration systems for both ASP.NET 1.1 and 2.0 are hierarchichal. As a result if a different framework version is a child of the root website (which is usually inetpubwwwroot), then the configuration system in the child will attempt to merge the configuration from the root website. This behavior is by design since both the 1.1 and 2.0 configuration systems walk up the physical directory structure looking for parent web.configs.

A simple workaround is to move the
common 2.0 configuration information
to the root web.config file for the
2.0 framework. The root web.config is located at:
C:windowsMicrosoft.NETFrameworkv2.0.50727CONFIG.
With this approach all of your 2.0
applications will pick up the common
sections while 1.1 applications won’t
see the sections.

Thank you for submitting this issue.
Hope the above information is useful
for you.

Posted by Microsoft on 22/02/2008 at
17:35

Seems to work for me, though it’s not quite as elegant as if it had been a .net 2.0 application. Hope this helps someone else.

Dan

Method 3

Most of the sections in Web.config can have a tag added to them – it might be worth adding this to the affected sections to see if it solves your inheritance probem (see Is it possible to completely negate a “higher” web.config in a subfolder? for some caveats to watch out for).


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x