C# 读取web.config配置文件 读取连接字符串

1. <connectionStrings>
<add name="mysql" connectionString="localhost"
providerName="System.Data.SqlClient" />
</connectionStrings>

string s = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["mysql"].ToString();


 

2. <appSettings>
<add key="mongodb" value="MongoDB:localhost" />
</appSettings>

string s = System.Configuration.ConfigurationManager.AppSettings["mongodb"].ToString();

posted on 2017-11-09 17:44  yanmay  阅读(5052)  评论(0编辑  收藏  举报

导航