62,025
社区成员
发帖
与我相关
我的任务
分享
Configuration webConfig = WebConfigurationManager.OpenWebConfiguration("/Web.config");
AppSettingsSection app = webConfig.AppSettings;
app.Settings[key].Value = value;
webConfig.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("web.config"));
XmlNode node;
XmlElement element;
node = doc.SelectSingleNode("//appSettings");
element = (XmlElement)node.SelectSingleNode("//add[@key='" + key + "']");
element.SetAttribute("value", value);
doc.Save(Server.MapPath("web.config"));