在 .NET Framework 2.0中,ConfigurationManager類新增了兩個屬性AppSettings和ConnectionStrings專門用來獲取配置文件AppSettings和ConnectionStrings節的數據,使用方法如下:
復制代碼 代碼如下:
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = ConfigurationManager.ConnectionStrings["connectionStringsName"].ToString();
Label2.Text = ConfigurationManager.AppSettings["appSettingsName"].ToString();
}
}