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();
If you mean the codes that run after This code by "first page load" this is something normal.
Config file just lunches after a request . 午餐。
i think the only solution is making that extra page load.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.