手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >web.config使用方法指南
web.config使用方法指南
摘要:外部文件db.config:复制代码代码如下:具体格式注意点1.如果指定了configSource,就以外部文件为准,web.config中...

<connectionStrings configSource="db.config"/>

外部文件db.config:

复制代码 代码如下:

<connectionStrings>

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)v11.0;Initial Catalog=aspnet-WebApplication1-20140304225906;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnet-WebApplication1-20140304225906.mdf"

providerName="System.Data.SqlClient" />

<add name="ReportServerTempDBConnectionString" connectionString="Data Source=.;Initial Catalog=ReportServerTempDB;Integrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

具体格式

<节点名 configSource="配置文件路径"/>

注意点

1.如果指定了configSource,就以外部文件为准,web.config中connectionStrings下面的节点配置就无效了,即使web.config中connectionStrings下面的连接串节点没有删除掉也是无效的。

2.外部文件的根节点必须与web.config中指定的节点相同(其实就是将该节点的配置移到外部文件中)

3.一个节点只能指定一个外部配置文件,不能将多个节点的外部文件指定为同一个,如不能将connectionStrings与appSettings的configSource指定为同一个文件。

节点的数据获取

ConfigurationManager.GetSection("节点名");//返回的是一个节点对象

假想:架设以后ASP.NET5跨平台,使用json当做配置文件,应该也可以同样实现吧!

以上所述就是本文的全部内容了,希望大家能够喜欢。

【web.config使用方法指南】相关文章:

c#中实现文件拖放打开的方法

ASP.NET中用healthMonitor属性用法

ashx中使用session的方法

.net 添加Cookie的4种方法

AspNetPager与Socut.Data使用方法

asp.net querystring乱码解决方法

log4net配置和使用方法分享

.net4.0中tuple元组的使用方法

web.config使用方法指南

ASP.NET Session使用详解

精品推荐
分类导航