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

后端 未结 7 1725
小鲜肉
小鲜肉 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条回答
  • 2020-11-22 14:57

    Who likes directly to the point,

    In your Config

        <appSettings>
    
        <add key="Conf_id" value="71" />
    
      </appSettings>
    

    in your code(c#)

    ///SET
        ConfigurationManager.AppSettings.Set("Conf_id", "whateveryourvalue");
          ///GET              
        string conf = ConfigurationManager.AppSettings.Get("Conf_id").ToString();
    
    0 讨论(0)
提交回复
热议问题