读取、重写 Web.config文件

1、读取

protected void Button1_Click(object sender, EventArgs e)   
    {     
        Label1.Text = ConfigurationManager.AppSettings["TestNode"].ToString();  
    } 


2、重写

Button2_Click(object sender, EventArgs e)  
{       
    Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath);      
    AppSettingsSection appSection = (AppSettingsSection)config.GetSection("appSettings");  
    appSection.Settings["TestNode"].Value = http:
    //www.cnblogs.com/wyjexplorer/archive/2011/11/02/TextBox1.Text;      
    config.Save();    
}

 

posted @ 2012-11-06 11:46  撸码兔兔  阅读(268)  评论(0编辑  收藏  举报