Configuration.GetSection Method

Definition

Returns the configuration section.

Overloads

GetSection(String)

Returns the configuration section by using the specified section path.

GetSection(String, String)

Returns the configuration section by using the specified section and location paths.

GetSection(String, Type)

Returns a strongly typed configuration section by using the specified section path.

GetSection(String, Type, String)

Returns a strongly typed configuration section by using the specified section and location paths.

GetSection(String)

Returns the configuration section by using the specified section path.

public:
 Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath);
public Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath);
member this.GetSection : string -> Microsoft.Web.Administration.ConfigurationSection
Public Function GetSection (sectionPath As String) As ConfigurationSection

Parameters

sectionPath
String

The path of the section to be returned.

Returns

The ConfigurationSection object.

Examples

The following example gets the <moduleProviders> section and displays the name of each element in the section.

public void GetGetSection(ServerManager manager)
{
    Configuration config = manager.GetAdministrationConfiguration();
    ConfigurationSection configSection = config.GetSection("moduleProviders");
    ConfigurationElementCollection elementCollection =
        configSection.GetCollection();
    Console.WriteLine("There are " + elementCollection.Count.ToString() +
        " elements in the section.");
    foreach (ConfigurationElement element in elementCollection)
    {
        Console.WriteLine("\t {0}", element.Attributes["name"].Value);
    }
}

Remarks

Configuration settings are contained in sections that group similar settings together for convenience. The GetSection(String) overload retrieves a configuration section by using its path.

Applies to

GetSection(String, String)

Returns the configuration section by using the specified section and location paths.

public:
 Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath, System::String ^ locationPath);
public Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath, string locationPath);
member this.GetSection : string * string -> Microsoft.Web.Administration.ConfigurationSection
Public Function GetSection (sectionPath As String, locationPath As String) As ConfigurationSection

Parameters

sectionPath
String

The path of the section to be returned.

locationPath
String

The location to search for the section.

Returns

The ConfigurationSection object.

Remarks

The GetSection(String, String) overload searches for the configuration section in a specified location.

Applies to

GetSection(String, Type)

Returns a strongly typed configuration section by using the specified section path.

public:
 Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath, Type ^ type);
public Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath, Type type);
member this.GetSection : string * Type -> Microsoft.Web.Administration.ConfigurationSection

Parameters

sectionPath
String

The path of the section to be returned.

type
Type

The .NET Framework type that represents the section.

Returns

The ConfigurationSection object.

Remarks

The GetSection(String, Type) overload returns a strongly typed configuration section in the specified section path.

Applies to

GetSection(String, Type, String)

Returns a strongly typed configuration section by using the specified section and location paths.

public:
 Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath, Type ^ type, System::String ^ locationPath);
public Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath, Type type, string locationPath);
member this.GetSection : string * Type * string -> Microsoft.Web.Administration.ConfigurationSection

Parameters

sectionPath
String

The path of the section to be returned.

type
Type

The .NET Framework type that represents the section

locationPath
String

The location to search for the section.

Returns

The ConfigurationSection object.

Remarks

The GetSection(String, Type, String) overload returns a strongly typed configuration section in the specified location and section path.

Applies to