protected void Page_Load(object sender, EventArgs e)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
//操作appSettings
AppSettingsSection appseting = (AppSettingsSection)config.GetSection("appSettings");
appseting.Settings["web"].Value = "测试"; //修改设置
appseting.Settings.Add("name", "测试"); //增加设置
// //操作connectionStrings
// ConnectionStringsSection conSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
//conSection.ConnectionStrings["constr"].ConnectionString = "htttp://study.pctoday.net.cn/App_Data/shaoqun.mdb"; //修改设置
// conSection.ConnectionStrings["constr"].ProviderName = "System.Data.OleDb";
//conSection.ConnectionStrings.Add(new ConnectionStringSettings("constr2", "aaaaa", "System.Data.OleDb")); //增加设置
//config.Save();
}
protected void Button1_Click(object sender, EventArgs e)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
//操作appSettings
AppSettingsSection appseting = (AppSettingsSection)config.GetSection("appSettings");
appseting.Settings["web"].Value = "测试"; //修改设置
appseting.Settings.Add("name", "测试");
config.Save();
}
asp.net 修改web.config
最新推荐文章于 2022-07-28 15:17:32 发布