移除所有对继承的节和节组的引用,仅允许那些由当前的 section 和 sectionGroup 元素添加的节和节组。
configuration 元素(常规设置架构)??configSections 元素(常规设置架构)
????configSections 的 clear 元素(常规设置架构)
??????configuration 元素(常规设置架构)
????????configSections 元素(常规设置架构)
??????????configSections 的 sectionGroup 元素(常规设置架构)
????????????configSections 的 clear 元素(常规设置架构)
<clear /> |
属性和元素
下面几部分描述了属性、子元素和父元素。
属性
无。
子元素
无。
父元素
元素 | 说明 |
---|---|
configuration |
指定公共语言运行库和 .NET Framework 应用程序所使用的每个配置文件中均需要的根元素。 |
configSections |
指定配置节和命名空间声明。 |
sectionGroup |
定义配置节处理程序与配置节之间的关联。 |
备注
clear 元素移除所有对继承的节和节组的引用,仅允许那些由当前的 section 和 sectionGroup 元素添加的节和节组。
如果配置文件在处理程序引用被移除后尝试使用配置节,ASP.NET 将发出服务器错误“无法识别的配置节 element_name”。
示例
下面的代码示例演示如何在应用程序配置文件中使用 clear 元素清除以前在 Machine.config 文件中定义的节。
下面的代码取自 Machine.config 文件,其中声明两个节,即 sampleSection
和 anotherSampleSection
,这两个节在应用程序配置文件之前读取。
? | ![]() |
---|---|
<configuration> <configSections> <section name="sampleSection" type="System.Configuration.SingleTagSectionHandler" /> <section name="anotherSampleSection" type="System.Configuration.NameValueSectionHandler" /> </configSections> <sampleSection setting1="Value1" setting2="value two" setting3="third value" /> </configuration> |
下面的应用程序配置文件代码清除以前声明的所有节。应用程序无法使用或检索以前在 Machine.config 文件中声明的节中的设置。不过,应用程序可以使用 anotherSection
中的设置,因为 anotherSection
位于 clear 元素的后面。
<configuration>
<configSections>
<clear/>
<section name="anotherSection"
type="System.Configuration.NameValueSectionHandler" />
</configSections>
? | ![]() |
---|---|
</configuration> |
元素信息
配置节处理程序 |
不适用。 |
配置成员 |
|
可配置的位置 |
Machine.config 根级别的 Web.config 应用程序级别的 Web.config 虚拟或物理目录级别的 Web.config |
要求 |
Microsoft Internet 信息服务 (IIS) 版本 5.0、5.1 或 6.0 .NET Framework 版本 1.0、1.1 或 2.0 Microsoft Visual Studio 2003 或 Visual Studio 2005 |
请参见
参考
configSections 元素(常规设置架构)configSections 的 sectionGroup 元素(常规设置架构)
configSections 的 section 元素(常规设置架构)
configSections 的 remove 元素(常规设置架构)
configuration 元素(常规设置架构)
概念
其他资源
常规配置设置 (ASP.NET)ASP.NET 配置设置
