How do I stop web.config inheritance

时光怂恿深爱的人放手 提交于 2019-12-17 18:56:32

问题


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


回答1:


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



回答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:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG

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 inetpub\wwwroot), 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:\windows\Microsoft.NET\Framework\v2.0.50727\CONFIG. 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




回答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).



来源:https://stackoverflow.com/questions/1049573/how-do-i-stop-web-config-inheritance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!