WebConfigurationManager.GetSection Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Récupère la section de configuration spécifiée à partir du fichier de configuration par défaut de l’application actuelle.
Surcharges
GetSection(String) |
Récupère la section de configuration spécifiée à partir du fichier de configuration de l’application actuelle. |
GetSection(HttpContext, String) |
Récupère la section de configuration spécifiée à partir du fichier de configuration de l’application en relation avec le contexte spécifié. |
GetSection(String, String, String) |
Récupère la section de configuration spécifiée à l’aide du nom du site web, du chemin d’accès virtuel et du chemin de la section. |
GetSection(HttpContext, String, Type) |
Récupère la section de configuration spécifiée à l’aide du type de section de configuration spécifié à partir du fichier de configuration de l’application en relation avec le contexte spécifié. |
GetSection(String, String, String, Type) |
Récupère la section de configuration spécifiée à l’aide du nom du site web, du chemin d’accès virtuel, du chemin de section et du type d’exécution. |
GetSection(String)
Récupère la section de configuration spécifiée à partir du fichier de configuration de l’application actuelle.
public:
static Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath);
public static Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath);
static member GetSection : string -> Microsoft.Web.Administration.ConfigurationSection
Public Shared Function GetSection (sectionPath As String) As ConfigurationSection
Paramètres
- sectionPath
- String
Nom de la section de configuration.
Retours
Objet de la section de configuration spécifiée ou null
si la section n'existe pas.
Exceptions
Impossible de charger un fichier de configuration valide.
Remarques
Si la GetSection(String) surcharge est appelée à partir d’une application web, elle retourne la section du fichier de configuration sélectionné par le système en fonction de la hiérarchie de configuration de l’application web.
Attention
Si votre application utilise un protocole autre que HTTP, vous devez utiliser la GetSection(HttpContext, String) surcharge ou GetSection(String, String, String, Type) , chacune d’elles prend à la fois un nom de section et un System.Web.HttpContext objet dans sa liste de paramètres. Vous devez spécifier pour HttpContext permettre au système de retourner les paramètres de configuration à un niveau de hiérarchie de configuration particulier. Toutefois, si le chemin de configuration spécifié se trouve en dehors de l’application actuelle et GetSectionGetSection(String, String, String, Type) retourne les paramètres de configuration au niveau de l’application pour l’application en cours d’exécution. Si vous utilisez GetSection(String), qui ne prend qu’un nom de section, le système tente toujours de retourner les paramètres de configuration au niveau de l’application.
Important
L’utilisation de GetSection(String) comme opération d’exécution est limitée par les restrictions de sécurité. Par exemple, vous ne pourrez peut-être pas accéder ou modifier une section au moment de l’exécution.
S’applique à
GetSection(HttpContext, String)
Récupère la section de configuration spécifiée à partir du fichier de configuration de l’application en relation avec le contexte spécifié.
public:
static Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::Web::HttpContext ^ context, System::String ^ sectionPath);
public static Microsoft.Web.Administration.ConfigurationSection GetSection (System.Web.HttpContext context, string sectionPath);
static member GetSection : System.Web.HttpContext * string -> Microsoft.Web.Administration.ConfigurationSection
Public Shared Function GetSection (context As HttpContext, sectionPath As String) As ConfigurationSection
Paramètres
- context
- HttpContext
HttpContext de la demande en cours.
- sectionPath
- String
Nom de la section de configuration.
Retours
Objet de la section de configuration spécifiée ou null
si la section n'existe pas.
Exceptions
Impossible de charger un fichier de configuration valide.
Remarques
Si la GetSection(HttpContext, String) surcharge est appelée à partir d’une application web, elle retourne la section du fichier de configuration sélectionné par le système en fonction de l’objet System.Web.HttpContext de l’application web.
Attention
Si votre application utilise un protocole autre que HTTP, vous devez utiliser la GetSection(HttpContext, String) surcharge ou GetSection(String, String, String, Type) , chacun d’eux prend un nom de section et un HttpContext dans sa liste de paramètres. Vous devez spécifier pour HttpContext permettre au système de retourner les paramètres de configuration à un niveau de hiérarchie de configuration particulier. Toutefois, si le chemin de configuration spécifié se trouve en dehors de l’application actuelle et GetSection(HttpContext, String)GetSection(String, String, String, Type) retourne les paramètres de configuration au niveau de l’application pour l’application en cours d’exécution. Si vous utilisez la GetSection(String) surcharge, qui ne prend qu’un nom de section, le système tente toujours de retourner les paramètres de configuration au niveau de l’application.
Important
L’utilisation de GetSection(HttpContext, String) comme opération d’exécution est limitée par les restrictions de sécurité. Par exemple, vous ne pourrez peut-être pas accéder ou modifier une section au moment de l’exécution.
S’applique à
GetSection(String, String, String)
Récupère la section de configuration spécifiée à l’aide du nom du site web, du chemin d’accès virtuel et du chemin de la section.
public:
static Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ siteName, System::String ^ virtualPath, System::String ^ sectionPath);
public static Microsoft.Web.Administration.ConfigurationSection GetSection (string siteName, string virtualPath, string sectionPath);
static member GetSection : string * string * string -> Microsoft.Web.Administration.ConfigurationSection
Public Shared Function GetSection (siteName As String, virtualPath As String, sectionPath As String) As ConfigurationSection
Paramètres
- siteName
- String
Nom du site Web.
- virtualPath
- String
Chemin d’accès virtuel du fichier Web.config.
- sectionPath
- String
Nom de la section de configuration.
Retours
Objet ConfigurationSection.
Exceptions
Impossible de charger un fichier de configuration valide.
L’un des paramètres passés à la méthode est null
.
Remarques
La GetSection(String, String, String) surcharge retourne un ConfigurationSection objet qui représente la configuration de l’emplacement demandé. Cette méthode recherche d’abord le site web demandé dans le siteName
paramètre, puis recherche le fichier Web.config dans le spécifié virtualPath
. GetSection(String, String, String) recherche ensuite dans le fichier Web.config la configuration sectionPath
demandée .
Important L’utilisation de GetSection(String, String, String) comme opération d’exécution est limitée par les restrictions de sécurité. Par exemple, vous ne pourrez peut-être pas accéder ou modifier une section au moment de l’exécution
S’applique à
GetSection(HttpContext, String, Type)
Récupère la section de configuration spécifiée à l’aide du type de section de configuration spécifié à partir du fichier de configuration de l’application en relation avec le contexte spécifié.
public:
static Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::Web::HttpContext ^ context, System::String ^ sectionPath, Type ^ sectionType);
public static Microsoft.Web.Administration.ConfigurationSection GetSection (System.Web.HttpContext context, string sectionPath, Type sectionType);
static member GetSection : System.Web.HttpContext * string * Type -> Microsoft.Web.Administration.ConfigurationSection
Public Shared Function GetSection (context As HttpContext, sectionPath As String, sectionType As Type) As ConfigurationSection
Paramètres
- context
- HttpContext
Objet HttpContext de la demande actuelle.
- sectionPath
- String
Nom de la section de configuration.
- sectionType
- Type
Type de section de configuration
Retours
Objet de la section de configuration spécifiée ou null
si la section n'existe pas.
Exceptions
Impossible de charger un fichier de configuration valide.
L’un des paramètres passés à la méthode est null
.
La valeur du sectionType
paramètre ne dérive pas de la ConfigurationSection classe ou ne fournit pas de constructeur public.
Remarques
Si la GetSection(HttpContext, String, Type) surcharge est appelée à partir d’une application web, elle retourne la section du fichier de configuration sélectionné par le système en fonction de l’objet System.Web.HttpContext de l’application web ainsi que des sectionPath
paramètres et sectionType
fournis.
Attention
Si votre application utilise un protocole autre que HTTP, vous devez utiliser la GetSection(HttpContext, String) surcharge ou GetSection(String, String, String, Type) , chacun d’eux prend un nom de section et un HttpContext dans sa liste de paramètres. Vous devez spécifier pour HttpContext permettre au système de retourner les paramètres de configuration à un niveau de hiérarchie de configuration particulier. Toutefois, si le chemin de configuration spécifié se trouve en dehors de l’application actuelle et GetSection(HttpContext, String)GetSection(String, String, String, Type) retourne les paramètres de configuration au niveau de l’application pour l’application en cours d’exécution. Si vous utilisez la GetSection(String) surcharge, qui ne prend qu’un nom de section, le système tente toujours de retourner les paramètres de configuration au niveau de l’application.
Important
L’utilisation de GetSection(HttpContext, String, Type) comme opération d’exécution est limitée par les restrictions de sécurité. Par exemple, vous ne pourrez peut-être pas accéder ou modifier une section au moment de l’exécution.
S’applique à
GetSection(String, String, String, Type)
Récupère la section de configuration spécifiée à l’aide du nom du site web, du chemin d’accès virtuel, du chemin de section et du type d’exécution.
public:
static Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ siteName, System::String ^ virtualPath, System::String ^ sectionPath, Type ^ sectionType);
public static Microsoft.Web.Administration.ConfigurationSection GetSection (string siteName, string virtualPath, string sectionPath, Type sectionType);
static member GetSection : string * string * string * Type -> Microsoft.Web.Administration.ConfigurationSection
Public Shared Function GetSection (siteName As String, virtualPath As String, sectionPath As String, sectionType As Type) As ConfigurationSection
Paramètres
- siteName
- String
Nom du site Web.
- virtualPath
- String
Chemin d’accès virtuel du fichier Web.config.
- sectionPath
- String
Nom de la section de configuration.
- sectionType
- Type
Type d’exécution de la section de configuration.
Retours
Objet ConfigurationSection.
Remarques
La GetSection(String, String, String, Type) surcharge retourne un ConfigurationSection objet qui représente la configuration de l’emplacement demandé. Cette méthode recherche d’abord le site web demandé dans le siteName
paramètre, puis recherche le fichier Web.config dans le spécifié virtualPath
. GetSection(String, String, String, Type) recherche ensuite dans le fichier Web.config la configuration sectionPath
demandée qui correspond au type d’exécution fourni dans le sectionType
paramètre.
Important
L’utilisation de GetSection(String, String, String, Type) comme opération d’exécution est limitée par les restrictions de sécurité. Par exemple, vous ne pourrez peut-être pas accéder ou modifier une section au moment de l’exécution.