In ASP. net2.0, we can easily access the configuration file. In netframework2.0, The systemwebsectiongroup class is added.
Allows users to access the configuration file programmatically
System. Web Group.
For example, you can determine whether the Web. config file is DEBUG = "true" or the authentication form.
Systemwebsectiongroup Ws = new systemwebsectiongroup ();
Compilationsection CP = ws. compilation;
You can use CP. Debug to obtain the "debug" configuration in the compilation section.
Authenticationsection as = ws. authentication;
You can use as. mode to obtain the "Mode" configuration in the authentication section. The value is one of the authenticationmode enumerated values.
The authenticationmode value is as follows:
| |
Member name |
Description |
| |
Forms |
Specify the Authentication Mode Based on ASP. NET forms. |
| |
None |
No authentication is specified. |
| |
Passport |
Set Microsoft Passport to Authentication mode. |
| |
Windows |
Specify windows as authentication mode. This mode is applicable when you use the Internet Information Service (IIS) authentication method (basic, brief, integrated windows (NTLM/Kerberos) or certificate. |
Appendix: Public attributes of the systemwebsectiongroup class:
| |
Name |
Description |
|
Anonymousidentification |
ObtainAnonymousidentificationSection. |
|
Authentication |
ObtainAuthenticationSection. |
|
Authorization |
ObtainAuthorizationSection. |
|
Browsercaps |
ObtainBrowsercapsSection. |
|
Clienttarget |
ObtainClienttargetSection. |
|
Compilation |
ObtainCompilationSection. |
|
Customerrors |
ObtainCustomerrorsSection. |
|
Deployment |
ObtainDeploymentSection. |
|
Devicefilters |
ObtainDevicefiltersSection. |
|
Globalization |
ObtainGlobalizationSection. |
|
Healthmonitoring |
ObtainHealthmonitoringSection. |
|
Hostingenvironment |
ObtainHostingenvironmentSection. |
|
Httpcookies |
ObtainHttpcookiesSection. |
|
Httphandlers |
ObtainHttphandlersSection. |
|
Httpmodules |
ObtainHttpmodulesSection. |
|
Httpruntime |
ObtainHttpruntimeSection. |
|
Identity |
ObtainIdentitySection. |
|
Isdeclarationrequired |
Gets a value indicating whether to declare thisConfigurationsectiongroupObject. (Inherited from configurationsectiongroup .) |
|
Isdeclared |
Gets a value that indicates whether thisConfigurationsectiongroupObject. (Inherited from configurationsectiongroup .) |
|
Machinekey |
ObtainMachinekeySection. |
|
Membership |
ObtainMembershipSection. |
|
Mobilecontrols |
ObtainMobilecontrolsSection. |
|
Name |
Obtain thisConfigurationsectiongroupObject Name attribute. (Inherited from configurationsectiongroup .) |
|
Pages |
ObtainPagesSection. |
|
Processmodel |
ObtainProcessmodelSection. |
|
Profile |
ObtainProfileSection. |
|
Protocols |
ObtainProtocolsSection. |
|
Rolemanager |
ObtainRolemanagerSection. |
|
Sectiongroupname |
ObtainConfigurationsectiongroupThe name of the associated node group. (Inherited from configurationsectiongroup .) |
|
Sectiongroups |
Obtain an object that contains allConfigurationsectiongroupObjectConfigurationsectiongroupObject.ConfigurationsectiongroupThe sub-object of the object. (Inherited from configurationsectiongroup .) |
|
Sections |
Gets a configurationsectioncollection that containsConfigurationsectiongroupAll configurationsection objects in. (Inherited from configurationsectiongroup .) |
|
SecurityPolicy |
ObtainSecurityPolicySection. |
|
Sessionstate |
ObtainSessionstateSection. |
|
Sitemap |
ObtainSitemapSection. |
|
Trace |
ObtainTraceSection. |
|
Trust |
ObtainTrustSection. |
|
Type |
Obtain or set thisConfigurationsectiongroupObject type. (Inherited from configurationsectiongroup .) |
|
Urlmappings |
ObtainUrlmappingsSection. |
|
Webcontrols |
ObtainWebcontrolsSection. |
|
Webparts |
ObtainWebpartsSection. |
|
WebServices |
ObtainWebServicesSection. |
|
Xhtmlconformance |
ObtainXhtmlconformanceSection. |