I have below code running. Changing an appSetting in my webconfig. But I have to make a extra pageload to "make the magic".
1st. pageload. uses previous setting. second pageload. Okay.
I have it placed inside Page_PreInit
:
Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection appSettings = (AppSettingsSection)configuration.GetSection("appSettings");
appSettings.Settings["FileManager"].Value = "newValue";
configuration.Save();