Handling configuration settings in asp.net web application

后端 未结 4 489
生来不讨喜
生来不讨喜 2021-01-14 07:42

I have a web application with over 200 configuration settings. These control everything from UI to Business logic.

Should these be retrieved on application startup o

4条回答
  •  失恋的感觉
    2021-01-14 08:07

    Per MSDN ISettings is used for hosting settings in VS Tools -> Options. Doesn't seem like a good candidate for a web app. Typically app settings are loaded on demand using ConfiguraionManager.Appsettings["keyname"] to get the most current value of the specified key. You can always cache the setting on Application_start if you you know for sure that the value will never change while the application is alive, but the benefit of reading it every time from web.Confg using ConfigurationManager.AppSettings["keyname"] is that the ASP.NET runtime will detect changes to web.config(such as when you modify a app setting value) and give you the most current value for the key.

提交回复
热议问题