编程语言
首页 > 编程语言> > Asp.net-读取App.config

Asp.net-读取App.config

作者:互联网

读取App.config

1.添加引用 System.Configuration.dll

2.using System.Configuration;

3.ConfigurationManager.AppSettings[key]

<!-- xml -->
<appSettings>
    <add key="ref" value="1" />
    <add key="dll" value="2" />
</appSettings>
var dll = ConfigurationManager.AppSettings["dll"];//1
var @ref = ConfigurationManager.AppSettings["ref"];//2

读取数据库连接字符串

var str = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

标签:Asp,读取,ConfigurationManager,AppSettings,App,ConnectionString,dll,var,net
来源: https://www.cnblogs.com/toyz9/p/14071507.html