WebConfigurationManager.GetWebApplicationSection メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim sectionName As String Dim returnValue As Object returnValue = WebConfigurationManager.GetWebApplicationSection(sectionName)
戻り値
指定した構成セクション オブジェクト。指定したセクションが存在しない場合は null 参照 (Visual Basic では Nothing)。このセクションに実行時にアクセスできない場合は内部オブジェクト。


GetWebApplicationSection は、Web アプリケーション内で呼び出された場合、Web アプリケーション構成階層に基づいて、システムによって選択された構成ファイルからセクションを取得します。
GetWebApplicationSection は、クライアント アプリケーション内から呼び出すことができます。この場合、クライアント構成階層に基づいてシステムによって選択された構成ファイルから既定のセクションを取得します。通常は Machine.config ファイルになりますが、割り当てられた構成が配置されている場合は除きます。構成ファイルの割り当てについては、次で説明する割り当て方法を参照してください。
![]() |
---|
GetWebApplicationSection は実行時の操作で、現在のレベルに存在するアプリケーション構成ファイルのセクションに対して動作します。一方、GetSection メソッドは実行時の操作ではありませんが、構成ファイルを開くためのメソッドのいずれかを使用して取得された、指定したセクションに対して動作します。 |

GetWebApplicationSection メソッドを使用して構成情報にアクセスする方法を次のコード例に示します。
' Show the use of GetWebApplicationSection(string). ' If called from within a Web aplication it gets the ' section from the configuration file located at the ' application current level. ' Its behavior is similar to GetSection(string) Shared Sub GetWebApplicationSection() ' Get the default connectionStrings section, Dim connectionStringsSection As ConnectionStringsSection = _ WebConfigurationManager.GetWebApplicationSection( _ "connectionStrings") ' Get the connectionStrings key,value pairs collection. Dim connectionStrings As ConnectionStringSettingsCollection = _ connectionStringsSection.ConnectionStrings ' Get the collection enumerator. Dim connectionStringsEnum As IEnumerator = _ connectionStrings.GetEnumerator() ' Loop through the collection and ' display the connectionStrings key, value pairs. Dim i As Integer = 0 Console.WriteLine("[Display connectionStrings]") While connectionStringsEnum.MoveNext() Dim name As String = connectionStrings(i).Name Console.WriteLine("Name: {0} Value: {1}", _ name, connectionStrings(name)) i += 1 End While Console.WriteLine() End Sub 'GetWebApplicationSection
// Show the use of GetWebApplicationSection(string). // If called from within a Web aplication it gets the // section from the configuration file located at the // application current level. // Its behavior is similar to GetSection(string) static void GetWebApplicationSection() { // Get the default connectionStrings section, ConnectionStringsSection connectionStringsSection = WebConfigurationManager.GetWebApplicationSection( "connectionStrings") as ConnectionStringsSection; // Get the connectionStrings key,value pairs collection. ConnectionStringSettingsCollection connectionStrings = connectionStringsSection.ConnectionStrings; // Get the collection enumerator. IEnumerator connectionStringsEnum = connectionStrings.GetEnumerator(); // Loop through the collection and // display the connectionStrings key, value pairs. int i = 0; Console.WriteLine("[Display connectionStrings]"); while (connectionStringsEnum.MoveNext()) { string name = connectionStrings[i].Name; Console.WriteLine("Name: {0} Value: {1}", name, connectionStrings[name]); i += 1; } Console.WriteLine(); }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からWebConfigurationManager.GetWebApplicationSection メソッドを検索する場合は、下記のリンクをクリックしてください。

- WebConfigurationManager.GetWebApplicationSection メソッドのページへのリンク