configSections的使用方法:
configSections节点必须定义在开始位置【相当于<Configuration></Configuration>的第一个元素】
可以定义section节点,也可以配置sectionGroup节点
<configSections> <sectionGroup name="WebSiteConfig"> <section name="dbProviders" type="ZC.DBUtility.WebSiteInfoHandler,ZC.DBUtility"/> <section name="fileUploadPath" type="ZC.DBUtility.WebSiteInfoHandler,ZC.DBUtility"/> </sectionGroup> </configSections>
及
<configSections> <section name="CustomConfig" type="OrderMvc.CustomConfig, OrderMvc"/> </configSections>
上述两种都是可以的
获取上述两种配置节点的值通过ConfigurationManager.GetSection()方法
获取sectionGroup节点
RouteSection section =ConfigurationManager.GetSection(“WebSiteConfig/dbProviders”) as RouteSection; RouteSection section =ConfigurationManager.GetSection(“CustomConfig”) as RouteSection;