Retrieves the specified configuration section from the current Web application's configuration file.
The specified configuration section object, or null if the section does not exist. Remember that security restrictions exist on the use of WebConfigurationManager.GetSection(string) as a runtime operation. You might not be able to access a section at run time for modifications, for example.
If WebConfigurationManager.GetSection(string) is called from within a Web application, it gets the section from the configuration file selected by the system according to the Web-application configuration hierarchy.
If your application uses a different protocol than HTTP, the WebConfigurationManager.GetSection(string, string) overload that takes both a section name and a path in its parameter list is the one to use. You must specify the configuration file path because the system cannot make any assumptions about the configuration hierarchy level. If you use the WebConfigurationManager.GetSection(string) overload that takes only a section name, the system will always attempt to return the configuration settings at the application level. Note, though, that if its specified path is outside of the current application, the overload that takes a path will also return the application-level configuration settings for the currently running application.
You could call WebConfigurationManager.GetSection(string) from within a client application. In this case, it gets the default section from the configuration file selected by the system according to the client configuration hierarchy. Usually, this is the Machine.config file, unless you have a mapped configuration in place. For mapping configuration files, refer to the mapping methods described next.
The WebConfigurationManager.GetSection(string) method is a run-time method that operates on the section of a configuration file at the hierarchy level in which the application runs. For a non-run-time operation, use System.Configuration.Configuration.GetSection(string) instead. This method operates on the specified section of a configuration file that you obtain using one of the overloaded methods for opening a configuration file, erload:System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration.