读取webconfig里面的appSetting和connectionString

<appSettings>
    <add key="SiteURL" value="http://moss2007:7000" />
    <add key="WebURL" value="" />
  </appSettings>

 

在页面读取:

 private string siteUrl = ConfigurationManager.AppSettings["SiteURL"];

 

<connectionStrings>
    <!--<add name="LogDBConn" connectionString="Data Source=11.192.241.151;Initial Catalog=MOSS_Log;User ID=sa;Password=Password01!"/>-->
    <add name="LogDBConn" connectionString="Data Source=moss2007;Integrated Security=True;Initial Catalog=MOSS_Log" />
  </connectionStrings>

 

在页面读取:

string strLogDBConn = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["LogDBConn"].ToString();

 

posted @ 2014-12-06 09:53  天马3798  阅读(265)  评论(0编辑  收藏  举报