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

 

你可能感兴趣的:(Connection)