3步实现 .NET 3.5 /WebConfig 字符串的增加和读取
//rorger
//2010-11-4 12:54:29
一:
找到并删掉
<appSettings/>
<connectStrings/>
二:
增加下面两个测试
<appSettings>
<add key="appkey" value="appValue"/>
</appSettings>
<connectionStrings>
<add name="hello" connectionString="Helloworld"/>
</connectionStrings>
三:
读取的方法:
ConfigurationManager.ConnectionStrings["hello"].ToString()
ConfigurationManager.AppSettings["appKey"]
在Page_Load中加入
Response.Write(ConfigurationManager.ConnectionStrings["hello"].ToString());
Response.Write(ConfigurationManager.AppSettings["appKey"]);
输出:
HelloworldappValue