如何停止的LT和继承; configSections>在Web.Config中 [英] How to stop inheritance of <configSections>in Web.Config

查看:218
本文介绍了如何停止的LT和继承; configSections>在Web.Config中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您根本不能使用<位置路径=。 inheritInChildApplications =false的> 在你的web.config的某些部分,以告诉它忽略某些部分的继承(你会得到错误,如inheritInChildApplications属性未声明等第四,如果你尝试把它路段它不支持)。

例如,你可以不前或在&LT使用它; configSections> 。例如,你可以换你的<的System.Web> 标记中的位置标记,但我需要停止的任何继承在< configSections> ,我没有看到一个办法做到这一点。

我的子应用程序继承了一些,我的父母应用程序的Web配置在相同的配置设置IIS 7 在树中。我看没有办法把一个<清/> 无论是在configSecion标签,因为它是一个无效的标签,如果你尝试添加它有

你怎么知道它忽略节?


解决方案

这非常相同的问题被问上多次SO以及许多其他论坛和答案是或多或少相同,不,你不能使用位置/透明/删除configsection。

微软甚至在他们的线程答复如下。


  

发布Microsoft在2009年7月23日5:40 PM


 <清/>和<删除/>


  

从未对由于涉及试图合并相同部分,处理程序和节组定义不同难度configSections和sectionGroups实施。


  
  

我们考虑增加此类功能的VS 2010的发布,但我们决定不这样做有两个原因。


  
  

第一个是额外的复杂性带来了,很大一部分原因是部分处理程序和段组用于引导的配置系统。其结果是,允许在自举配置系统的中间合并语义是解决一个不平凡的问题。


  
  

第二个原因是,通常节处理程序和节组定义在两个不同的地方都做 - 一组初始登记达根的配置文件,然​​后一个的添加剂的设置应用程序注册的级别的Web.config。这并不意味着如果开发者希望修改处理程序的定义是无效的情况下 - 它只是一个可能性低的情况。
  感谢您抽出宝贵时间,虽然通过连接提交您的建议!



看看这个SO线程,这简单的状态避免使用有冲突的部分群体。

不过,Nairman提出以下,


  

我不知道,你可以在一个子文件夹不同的定义相同的部分;你可以使该子文件夹中的独立的虚拟应用程序,在这种情况下,它不会继承任何的从父的设置;在这种情况下,它也将执行在自己的应用程序池;如果你没有是InProc的依赖,这是一个选项,以及


<一个href=\"http://stackoverflow.com/questions/4030891/how-to-$p$pvent-inheritance-for-web-config-file-for-configsections\">how以prevent继承web.config文件&QUOT; configSections&QUOT;?

You simply cannot use <location path="." inheritInChildApplications="false"> in certain parts of your web.config in order to tell it to ignore inheritance of certain sections (you'll get errors such as 'inheritInChildApplications attribute is not declared' and so fourth if you try putting it in sections where it's not supported).

For example you can't use it before or inside <configSections>. You can for example wrap your <system.web> tag in the location tag but I need to stop inheritance of anything in <configSections> and I do not see a way to do this.

My sub application is inheriting some of the same config settings that my parent app's web config has in IIS 7 in the tree. I see no way to put a <clear/> either in the configSecion tag as it's an invalid tag if you try to add it there.

How do you tell it to ignore that section?

解决方案

This very same question was asked multiple times on SO as well as many other forums and answer was more or less the same, No you cannot use location/clear/remove for configsection.

Microsoft even replied on their thread as follows.

Posted by Microsoft on 7/23/2009 at 5:40 PM

 <clear /> and <remove />

were never implemented for configSections and sectionGroups because of the difficulty involved attempting to merge different definitions of the same section-handlers and section groups.

We considered adding this type of functionality for the VS 2010 release, but we decided against it for two reasons.

The first one being the additional complexity it brings, in large part because section handlers and section groups are used to bootstrap the configuration system. As a result allowing for merge semantics in the middle of bootstrapping the configuration system is a non-trivial problem to solve.

The second reason is that usually section handlers and section group definitions are made in two distinct places - an initial set of registrations up in the root configuration files, and then an additive set of registrations in application level web.config. That doesn't mean a scenario where a developer wants to modify handler definitions isn't valid - its just a low likelihood scenario. Thank you for taking the time though to submit your suggestion via Connect!


Check out this SO thread, which simple states avoid using conflicting section groups.

However, Nairman suggests following,

I'm not sure that you can have the same section defined differently in a sub-folder; you could make that sub-folder a stand-alone virtual application, in which case it wouldn't inherit any of the settings from the parent; in this scenario, it would also execute in its own app pool; if you don't have InProc dependencies, that's an option as well

how to prevent inheritance for web.config file for "configSections"?

这篇关于如何停止的LT和继承; configSections&gt;在Web.Config中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆