App_Code/common2/common/WebConfig.cs
(完整代码) 1KBusing System;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Xml;
namespace RM.Common
{
public class WebConfig
{
public static NameValueCollection GetAppSettings()
{
return ConfigurationManager.AppSettings;
}
/// <summary>
/// 修改web.config文件appSettings配置节中的Add里的value属性
/// </summary>
/// <remarks>
/// 注意,调用该函数后,会使整个Web Application重启,导致当前所有的会话丢失
/// </remarks>
public static void SetAppSettings(NameValueCollection Settings)
{
string XPath = "/configuration/appSettings/add[@key='?']";
XmlDocument domWebConfig = new XmlDocument();
domWebConfig.Load((System.Web.HttpContext.Current.Server.MapPath("/web.config")));
foreach (string key in Settings)
{
XmlNode addKey = domWebConfig.SelectSingleNode((XPath.Replace("?", key)));
if (addKey == null)
{
continue;
}
addKey.Attributes["value"].InnerText = Settings[key];
}
domWebConfig.Save((System.Web.HttpContext.Current.Server.MapPath("/web.config")));
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。