How do you modify the web.config appSettings at runtime?

后端 未结 7 1801
小鲜肉
小鲜肉 2020-11-22 14:28

I am confused on how to modify the web.config appSettings values at runtime. For example, I have this appSettings section:


  

        
7条回答
  •  -上瘾入骨i
    2020-11-22 14:52

    And if you want to avoid the restart of the application, you can move out the appSettings section:

    
    

    to a separate file. And in combination with ConfigurationSaveMode.Minimal

    var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
    config.Save(ConfigurationSaveMode.Minimal);
    

    you can continue to use the appSettings section as the store for various settings without causing application restarts and without the need to use a file with a different format than the normal appSettings section.

提交回复
热议问题