在web开发中一般我们读取web.config里面的信息,都是通过
WebConfigurationManager.AppSettings
WebConfigurationManager.ConnectionStrings
或者时候1.1里面老的方式实现IConfigurationSection,其实都无所谓了。
这里主要讨论一下使用ConfigurationSection抽象类的方式,定义配置节,可以实现多配置节,其实和IConfigurationSection一样,没感觉有什么很大区别。做个笔记而已了
首先web.config
1配置节点简单使用<configSections>
2配置节点简单使用  <section name="mqtest" type="test, __code"/>
3配置节点简单使用</configSections>
4配置节点简单使用<mqtest>
5配置节点简单使用  <aaForm asdfa="10"></aaForm>
6配置节点简单使用</mqtest>
调用
 1配置节点简单使用
 2
页面访问
配置节点简单使用test Settings1 = (test)WebConfigurationManager.GetSection("mqtest");
配置节点简单使用Settings1.tt 
= 100;

==============直接取属性
配置节点简单使用<system.web>
配置节点简单使用     
<httpRuntime maxRequestLength="4096" executionTimeout="120" ></httpRuntime>
配置节点简单使用
</system.web>
配置节点简单使用
配置节点简单使用Configuration config = WebConfigurationManager.OpenWebConfiguration(this.Request.ApplicationPath);
 HttpRuntimeSection myHttpRuntimeSection 
= (HttpRuntimeSection)config.GetSection("system.web/httpRuntime");



demo

相关文章: