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

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

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

<sectionGroup 
   name="section name"
   type="configuration section handler class, assembly file name, version, culture, public key token">
   <section />
</sectionGroup>

属性および要素

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

属性

属性

Description

name

必須の String 属性です。

type 属性に指定した構成セクション ハンドラーに関連付ける構成セクションまたは構成要素の名前を指定します。 この名前は、構成ファイルのセクション設定領域に group 要素の名前として示されます。

type

必須の String 属性です。

name 属性に指定したセクションまたは要素の構成設定の処理を行う構成セクション ハンドラー クラスの名前を指定します。 次の形式を使用します。

type="Fully qualified class name, assembly file name, version, culture, public key token"

定義はアセンブリ参照と一致する必要があります。 たとえば、次のコード例のバージョン番号がアセンブリと一致しなかった場合、エラーになります。

type="MyConfigSectionHandler.MyHandler,MyCustomConfigurationHandler,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"

アセンブリ ファイルは、それを定義している Web.config ファイルと同じアプリケーション ディレクトリに存在する必要があります。 ルート Web.config ファイルや Machine.config ファイルの場合、アセンブリ ファイルは %SystemRoot%\Microsoft.NET\Framework\version ディレクトリに存在する必要があります。

子要素

要素

Description

section

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

sectionGroup

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

親要素

要素

Description

configuration

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

configSections

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

sectionGroup

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

解説

sectionGroup 要素は、section 要素のコンテナーとして機能します。 section 要素は、構成セクション ハンドラーを構成要素または構成セクションに関連付けます。 この処理が必要なのは、ASP.NET が構成ファイル内の設定の処理方法について推測を一切行わないからです。 代わりに、ASP.NET は構成データの処理を構成セクション ハンドラーにデリゲートします。 各 section 要素は、構成セクションまたは構成要素と、その構成セクションまたは構成要素を処理する ConfigurationSection クラスの派生関連クラスを示します。 section 要素を sectionGroup 要素に論理的にグループ化すると、 section 要素を整理し、名前の競合を防ぐことができます。 section 要素と sectionGroup 要素は、configSections 要素に格納されます。

既定の構成

.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>
      <sectionGroup name="mySectionGroup">
         <section name="mySection"
            type="System.Configuration.NameValueSectionHandler" />
      </sectionGroup>
   </configSections>
   <mySectionGroup>
      <mySection>
         <add key="key1" value="value1" />
      </mySection>
   </mySectionGroup>
</configuration>

要素情報

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

該当なし

構成メンバー

ConfigurationSectionGroup

構成できる場所

Machine.config

ルート レベルの Web.config

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

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

要件

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

.NET Framework Version 2.0

Microsoft Visual Studio 2003 または Visual Studio 2005

参照

Reference

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

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

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

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

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

概念

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