读取、重写 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(); }

浙公网安备 33010602011771号