Created
December 3, 2014 11:44
-
-
Save Saanch/ffdef63369a4abafe9fd to your computer and use it in GitHub Desktop.
Updating config value from the db at application initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); | |
IDictionary<string, string> staticAppSettings = ConfigService.GetStaticAppSettings(); | |
foreach (var setting in staticAppSettings) | |
{ | |
if (ConfigurationManager.AppSettings[setting.Key] == null) | |
config.AppSettings.Settings.Add(setting.Key, setting.Value); | |
else | |
ConfigurationManager.AppSettings[setting.Key] = setting.Value; | |
} | |
config.Save(); | |
ConfigurationManager.RefreshSection("appSettings"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment