SYSK 187: The New Way to Get Configuration Settings

In ASP.NET 2.0, you can use the new class – WebConfigurationManager – to access machine and application information.  Better yet, there are a number of framework classes that allow for strongly-typed access of configuration section settings.  For example, to get the current trust level specified as:

<system.web>

  <trust level="Full" originUrl=""/>

</system.web>

 

you would execute something like this:

System.Web.Configuration.TrustSection section = System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection("system.web/trust") as System.Web.Configuration.TrustSection;

        Response.Write(section.Level);

 

Here is a list of all (?) classes representing configuration sections, in alphabetical order:

· AnonymousIdentificationSection

· AppSettingsSection

· AuthenticationModulesSection

· AuthenticationSection

· AuthorizationSection

· CacheSection

· ClientSettingsSection

· ClientTargetSection

· CompilationSection

· ConnectionManagementSection

· ConnectionStringsSection

· CustomErrorsSection

· DefaultProxySection

· DefaultSection

· DefaultSettingsSection

· DeploymentSection

· DeviceFiltersSection

· GlobalizationSection

· HealthMonitoringSection

· HostingEnvironmentSection

· HttpCookiesSection

· HttpHandlersSection

· HttpModulesSection

· HttpRuntimeSection

· IdentitySection

· IgnoreSection

· ImageGenerationSection

· MachineKeySection

· MachineSettingsSection

· MailSettingsSectionGroup

· MembershipSection

· NetSectionGroup

· OutputCacheSection

· OutputCacheSettingsSection

· PagesSection

· ProcessModelSection

· ProfileSection

· ProtectedConfigurationSection

· RequestCachingSection

· RoleManagerSection

· SecurityPolicySection

· SessionPageStateSection

· SessionStateSection

· SettingsSection

· SiteCountersSection

· SiteMapSection

· SmtpMailSection

· SmtpSection

· SqlCacheDependencySection

· TraceSection

· TransactionsSectionGroup

· TrustSection

· UrlMappingsSection

· WebControlsSection

· WebPartsSection

· WebRequestModulesSection

· WindowsFormsSection

· XhtmlConformanceSection