configSections 要素 (全般設定スキーマ)

[このドキュメントはプレビューのみを目的としており、以降のリリースで変更される可能性があります。プレースホルダーとして空白のトピックが含まれています。]

構成セクションと名前空間の宣言を指定します。

   <configSections>
      <section />
      <sectionGroup />
      <remove />
      <clear/>
   </configSections>

属性および要素

以降のセクションでは、属性、子要素、および親要素について説明します。

属性

なし。

子要素

要素

Description

clear

継承したセクションとセクション グループへのすべての参照を削除し、現在の section 要素と sectionGroup 要素によって追加されたセクションとセクション グループだけを有効にします。

remove

継承したセクションおよびセクション グループへの参照を削除します。

section

構成セクション ハンドラーと構成要素の間の関連付けを定義します。

sectionGroup

構成セクション ハンドラーと構成セクションの間の関連付けを定義します。

親要素

要素

Description

configuration

共通言語ランタイムおよび .NET Framework アプリケーションで使用されるすべての構成ファイルで必要なルート要素を指定します。

解説

configSections 要素は、構成セクションとハンドラー宣言を指定します。 ASP.NET は構成ファイル内の設定の処理方法について一切仮定を行わないため、この処理が必要になります。 代わりに、ASP.NET は構成データの処理を構成セクション ハンドラーにデリゲートします。

各 section 要素は、構成セクションまたは構成要素と、構成セクションまたは構成要素を処理する、関連付けれた ConfigurationSection 派生クラスを識別します。 section 要素を sectionGroup 要素に論理的にグループ化すると、section 要素を整理し、名前の競合を防ぐことができます。 section 要素と sectionGroup 要素は、configSections 要素に格納されます。

configSections 要素を構成ファイルで使用する場合は、configSections 要素を configuration 要素の最初の子要素にする必要があります。

既定の構成

.NET 構成要素の構成セクションは Machine.config ファイルで定義されますが、数が非常に多いため、ここでは紹介していません。 system.web セクションの authentication 要素に対する構成セクション ハンドラーを定義する Machine.config ファイルの一部を以下に示します。 次に、authentication 要素に対して構成設定を定義します。

構成セクション ハンドラーが構成要素に関連付けられていない場合、ASP.NET は "認識できない構成セクション element_name" というサーバー エラーを発行します。

<configuration>
    <configSections>
        <sectionGroup name="system.web" type="System.Web.Configuration.SystemWebSectionGroup, System.Web, Version=%ASSEMBLY_VERSION%, Culture=neutral, PublicKeyToken=%MICROSOFT_PUBLICKEY%">
            <section name="authentication" type="System.Web.Configuration.AuthenticationSection, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowDefinition="MachineToApplication" />
            <!-- Other system.web sections -->
        </sectionGroup>
        <!-- Other configuration sections -->
    </configSections>

    <system.web>
        <authentication mode="Windows">
            <forms name=".ASPXAUTH" 
                   loginUrl="login.aspx" defaultUrl="default.aspx" 
                   protection="All" 
                   timeout="30" 
                   path="/" 
                   requireSSL="False" 
                   slidingExpiration="True" 
                   cookieless="UseCookies" 
                   domain="" 
                   enableCrossAppRedirects="False">
                <credentials passwordFormat="SHA1" />
            </forms>
            <passport redirectUrl="internal" />
        </authentication>
        <!-- Other system.web elements -->
    </system.web>
    <!-- Other configuration settings -->
</configuration>

使用例

カスタム構成セクションと、そのセクションの設定を定義するコード例を示します。

<configuration>

   <configSections>
      <section name="sampleSection"
               type="System.Configuration.SingleTagSectionHandler" />
   </configSections>

   <sampleSection setting1="Value1" 
                  setting2="value two" 
                  setting3="third value" />

</configuration>

要素情報

構成セクション ハンドラー

該当なし

構成メンバー

ConfigurationSectionCollection

ConfigurationSectionGroupCollection

構成できる場所

Machine.config

ルート レベルの Web.config

アプリケーション レベルの Web.config

仮想ディレクトリ レベルまたは物理ディレクトリ レベルの Web.config

要件

Microsoft Internet Information Services (IIS) バージョン 5.0、5.1、または 6.0

.NET Framework Version 1.0、1.1、または 2.0

Microsoft Visual Studio 2003 または Visual Studio 2005

参照

Reference

configuration 要素 (全般設定スキーマ)

configSections の section 要素 (全般設定スキーマ)

configSections の sectionGroup 要素 (全般設定スキーマ)

configSections の clear 要素 (全般設定スキーマ)

configSections の remove 要素 (全般設定スキーマ)

概念

ASP.NET Configuration File Hierarchy

Format of ASP.NET Configuration Files

Configuration Inheritance

その他の技術情報

全般構成設定 (ASP.NET)

ASP.NET 構成設定

ASP.NET Configuration Files

Configuring ASP.NET Applications

ASP.NET Configuration API