利用configSource將web.config的connectionStrings移到另一個config文档中维护

参考:http://www.dotblogs.com.tw/puma/archive/2010/01/25/aspnet-connectionstring-appsetting-file-configsource.aspx

原config文件

 
    
< connectionStrings >
< add name ="eshop" connectionString ="Data Source=(local);
Initial Catalog=tempdb;User ID=sa;"
providerName ="System.Data.SqlClient" />
connectionStrings >

 

  修改后

 

 

dbConnection.config文件

 

代码
 
     
xml version="1.0" encoding="utf-8" ?>
< connectionStrings >
< clear />
< add name ="eshop" connectionString ="Data Source=(local);
Initial Catalog=tempdb;User ID=sa;"
providerName ="System.Data.SqlClient" />
connectionStrings >

 

 

 appSettings 类似

<appSettings configSource="settings.config" />

 

xml version="1.0" encoding="utf-8"?>
<appSettings>
  <add key="Blog" value="F6 Team" />
  <add key="Name" value="puma" />
  <add key="skill" value="ASP.NET" />
appSettings>

 

 <appSettings file="settings.config">
    <add key="Blog" value="F6 Team" />
    <add key="Name" value="puma" />
  appSettings>

 

xml version="1.0" encoding="utf-8"?>
<appSettings>
  <add key="skill" value="ASP.NET" />
appSettings>

 

 

 

 

 

转载于:https://www.cnblogs.com/fightLonely/archive/2010/12/06/1898086.html

你可能感兴趣的:(利用configSource將web.config的connectionStrings移到另一個config文档中维护)