解决方法
This fellow显示示例代码,如果您仍然想在所有注意事项后执行:
protected void EditConfigButton(object sender,EventArgs e) { Configuration objConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); AppSettingsSection objAppsettings = (AppSettingsSection)objConfig.GetSection("appSettings"); //Edit if (objAppsettings != null) { objAppsettings.Settings["test"].Value = "newvalueFromCode"; objConfig.Save(); } }