asp.net mvc webconfig配置文件操作

读取web.config数据,可以不用编译。如发布后,非常有用
web.config文件
<configuration>
<appSettings> <add key="Pwd" value="yms6666" /> </appSettings> </configuration> c#后台代码读取Key为Pwd的数据
 string pwd= System.Configuration.ConfigurationManager.AppSettings["Pwd"];

 连接字符串:

return new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["WebJakeCS"].ConnectionString);

return new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["WebJakeCS"].ToString());

原文地址:https://www.cnblogs.com/gaocong/p/4969451.html