共用方式為


configSections 的 clear 項目 (一般設定結構描述)

移除已繼承之區段和區段群組的所有參考,只允許由目前 sectionsectionGroup 項目所加入的區段和區段群組。

<clear />

屬性和項目

下列各節將說明屬性、子項目和父項目。

屬性

無。

子項目

無。

父項目

項目

說明

configuration

指定 Common Language Runtime 和 .NET Framework 應用程式所使用之每個組態檔中需要的根項目 (Root Element)。

configSections

指定組態區段和命名空間宣告。

sectionGroup

在組態區段處理常式和組態區段之間定義關聯。

備註

clear 項目會移除已繼承之區段和區段群組的所有參考,只允許由目前 sectionsectionGroup 項目所加入的區段和區段群組。

如果組態檔嘗試在移除處理常式參考之後使用組態區段,則 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>

項目資訊

組態區段處理常式

不套用。

組態成員

Clear()

Clear()

可設定的位置

Machine.config

根層次的 Web.config

應用程式層級的 Web.config

虛擬或實體目錄層級的 Web.config

需求

Microsoft Internet Information Services (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 組態檔

ASP.NET 組態案例

其他資源

一般組態設定 (ASP.NET)

ASP.NET 組態設定

ASP.NET 組態檔

ASP.NET 網站管理

ASP.NET 組態 API