在Asp.Net2.0中可以方便的访问配置文件web.config,如判断debug设置,验证类型等


Asp.Net2.0中我们可以方便的访问配置文件中,.NetFrameWork2.0新增加了 SystemWebSectionGroup 类。

  允许用户以编程方式访问配置文件的 system.web 组。

  比如判断web.config内是否为 debug="true",或者判断身份验证形式

  SystemWebSectionGroup ws = new SystemWebSectionGroup();

  CompilationSection cp = ws.Compilation;

  用cp.Debug;就可以得到compilation节内关于"debug"的配置

   AuthenticationSection as = ws.Authentication;

  用 as.Mode 可以获取 authentication节中关于"mode"的配置,值为AuthenticationMode 枚举之一

  AuthenticationMode的取值如下:

  成员名称 说明

  Forms 将基于 ASP.NET 窗体的身份验证指定为身份验证模式。 

  None 不指定身份验证。 

  Passport 将 Microsoft Passport 指定为身份验证模式。 

  Windows 将 Windows 指定为身份验证模式。在使用 Internet 信息服务 (IIS) 身份验证方法(基本、简要、集成 Windows (NTLM/Kerberos) 或证书)时适用此模式。 

  附:SystemWebSectionGroup 类的公共属性:

  名称 说明 

  AnonymousIdentification 获取 anonymousIdentification 节。

  Authentication 获取 authentication 节。

  Authorization 获取 authorization 节。

  BrowserCaps 获取 browserCaps 节。

  ClientTarget 获取 clientTarget 节。

  Compilation 获取 compilation 节。

  CustomErrors 获取 customErrors 节。

  Deployment 获取 deployment 节。

  DeviceFilters 获取 deviceFilters 节。

  Globalization 获取 globalization 节。

  HealthMonitoring 获取 healthMonitoring 节。

  HostingEnvironment 获取 hostingEnvironment 节。

  HttpCookies 获取 httpCookies 节。

  HttpHandlers 获取 httpHandlers 节。

  HttpModules 获取 httpModules 节。

  HttpRuntime 获取 httpRuntime 节。

  Identity 获取 identity 节。

  IsDeclarationRequired  获取一个值,该值指示是否需要声明此 ConfigurationSectionGroup 对象。 (从 ConfigurationSectionGroup 继承。)

  IsDeclared  获取一个值,该值指示是否已声明此 ConfigurationSectionGroup 对象。(从 ConfigurationSectionGroup 继承。)

  MachineKey 获取 machineKey 节。

  Membership 获取 membership 节。

  MobileControls 获取 mobileControls 节。

  Name  获取此 ConfigurationSectionGroup 对象的名称属性。(从 ConfigurationSectionGroup 继承。)

  Pages 获取 pages 节。

  ProcessModel 获取 processModel 节。

  Profile 获取 profile 节。

  Protocols 获取 protocols 节。

  RoleManager 获取 roleManager 节。

  SectionGroupName  获取与此 ConfigurationSectionGroup 关联的节组名称。(从 ConfigurationSectionGroup 继承。)

  SectionGroups  获取一个包含所有 ConfigurationSectionGroup 对象的 ConfigurationSectionGroup 对象,这些对象是此 ConfigurationSectionGroup 对象的子对象。(从 ConfigurationSectionGroup 继承。)

  Sections  获取一个 ConfigurationSectionCollection,它包含此 ConfigurationSectionGroup 中的所有 ConfigurationSection 对象。(从 ConfigurationSectionGroup 继承。)

  SecurityPolicy 获取 securityPolicy 节。

  SessionState 获取 sessionState 节。

  SiteMap 获取 siteMap 节。

  Trace 获取 trace 节。

  Trust 获取 trust 节。

  Type  获取或设置此 ConfigurationSectionGroup 对象的类型。(从 ConfigurationSectionGroup 继承。)

  UrlMappings 获取 urlMappings 节。

  WebControls 获取 webControls 节。

  WebParts 获取 webParts 节。

  WebServices 获取 webServices 节。

  XhtmlConformance 获取 xhtmlConformance 节

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3