C# 修改通过';引用的自定义配置文件中的appSettings;文件';属性
在Web.config的C# 修改通过';引用的自定义配置文件中的appSettings;文件';属性,c#,asp.net-mvc,web-config,appsettings,C#,Asp.net Mvc,Web Config,Appsettings,在Web.config的appSettings部分中,使用file属性引用自定义配置文件。目标是能够在自定义配置中修改某些应用程序设置,而不会导致应用程序重新启动 Web.config 这也不管用 var configuration = WebConfigurationManager.OpenWebConfiguration("~/CustomAppSettings.config"); 我做错了什么?有人能给我指出正确的方向吗?使用configSource而不是file <appSett
appSettings
部分中,使用file
属性引用自定义配置文件。目标是能够在自定义配置中修改某些应用程序设置,而不会导致应用程序重新启动
Web.config
这也不管用
var configuration = WebConfigurationManager.OpenWebConfiguration("~/CustomAppSettings.config");
我做错了什么?有人能给我指出正确的方向吗?使用configSource而不是file
<appSettings configSource="CustomAppSettings.config" />
你找到解决办法了吗?@vhinn糟糕的是,我没有:(.见下面我的答案:)
var configuration = WebConfigurationManager.OpenWebConfiguration("~/");
configuration.AppSettings.Settings[key].Value = value.ToString();
configuration.Save();
var configuration = WebConfigurationManager.OpenWebConfiguration("~/CustomAppSettings.config");
<appSettings configSource="CustomAppSettings.config" />
var configuration = WebConfigurationManager.OpenWebConfiguration("~/");
configuration.AppSettings.Settings[key].Value = value.ToString();
configuration.Save(ConfigurationSaveMode.Minimal);