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

移除繼承區段和區段群組的參考。

<remove 
   name="section name" 
/>

屬性和項目

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

屬性

屬性

描述

name

必要的 String 屬性。

指定要移除的區段或區段群組的名稱。 這個屬性與加入參考之 sectionsectionGroup 項目中的 name 屬性相同。

子項目

無。

父項目

項目

描述

configuration

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

configSections

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

sectionGroup

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

備註

remove 項目會移除繼承區段或區段群組的參考。 使用 sectionsectionGroup 項目,可將新區段和區段群組加入目前組態檔中的集合。

如果組態檔嘗試在移除處理常式參考之後使用組態區段,則 ASP.NET 會發出伺服器錯誤「無法辨認的組態區段 element_name」。

範例

下列程式碼範例示範如何在應用程式組態檔中使用 remove 項目,以移除先前在 Machine.config 檔中定義的區段。

下列的 Machine.config 檔程式碼宣告名為 sampleSection 的區段。

<configuration>
   <configSections>
      <section name="sampleSection"
               type="System.Configuration.SingleTagSectionHandler" />
   </configSections>
   <sampleSection setting1="Value1" setting2="value two" 
                  setting3="third value" />
</configuration>

下列範例應用程式組態檔會移除 sampleSection 區段。 移除之後,應用程式就會無法擷取 sampleSection 中的設定。 如果組態檔嘗試在移除處理常式參考之後使用組態區段,則 ASP.NET 會發出伺服器錯誤「無法辨認的組態區段 element_name」。

<configuration>
   <configSections>
      <clear/>
      <section name="anotherSection"
               type="System.Configuration.NameValueSectionHandler" />
    </configSections>
</configuration>

項目資訊

組態區段處理常式

不套用。

組態成員

Remove(String)

Remove(String)

可設定的位置

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 的 clear 項目 (一般設定結構描述)

configuration 項目 (一般設定結構描述)

概念

ASP.NET 組態檔階層架構和繼承

編輯 ASP.NET 組態檔

ASP.NET 組態案例

其他資源

一般組態設定 (ASP.NET)

ASP.NET 組態設定

ASP.NET 組態檔

ASP.NET 網站管理

ASP.NET 組態 API