1. 程式人生 > >ASP.Net Web.config中引用外部config文件

ASP.Net Web.config中引用外部config文件

pset lin AD 配置 utf tostring pan OS add

Web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings configSource="Config\app.config"></appSettings>
</configuration>

Ps. configSource="Config\app.config",此處一定要使用反斜杠“\”;

Config\app.config file:

<?xml version="1.0"?>
<appSettings>
<add key="Version" value="1.0.0" />
<add key="Country" value="China"/>
</appSettings>

讀取配置文件值:

string value = ConfigurationManager.AppSettings["Country"].ToString();

ASP.Net Web.config中引用外部config文件