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());

posted @ 2015-11-16 17:08  小小高  阅读(8411)  评论(0编辑  收藏  举报