Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 修改通过';引用的自定义配置文件中的appSettings;文件';属性_C#_Asp.net Mvc_Web Config_Appsettings - Fatal编程技术网

C# 修改通过';引用的自定义配置文件中的appSettings;文件';属性

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

在Web.config的
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);