How to override settings.settings variable by app.config variable

前端 未结 5 1785
攒了一身酷
攒了一身酷 2021-01-18 04:32

How can I change (or override) a settings.settings variable by adding a variable to the app.config on production?

Is this possible anyway?

5条回答
  •  心在旅途
    2021-01-18 04:51

    Only through code:

    e.g.

     if (bool.Parse(ConfigurationManager.AppSettings["overridethis"].ToString()))
     {
         //use overridden value
     }
    

    If however, your issue is maintaining different configuration values in different environments, then I would use AppSettings instead.

    You can then use a developer override file.

     
    

    See http://www.compiledthoughts.com/2005/03/overriding-webconfig-app-settings-with.html

提交回复
热议问题