开发者

web.Config vs Database Settings table

开发者 https://www.devze.com 2023-02-03 12:21 出处:网络
When you have a system of multiple application, web services and windows s开发者_开发问答ervices, which is better option?

When you have a system of multiple application, web services and windows s开发者_开发问答ervices, which is better option?

Option 1) Put all settings in database table and cache it somewhere, probably you will have to use a web service to share the cache object across applications. You can then view some of those settings in a grid for user manipulation.

Option 2) Put all settings in a common configuration file, and let web.config or app.config of each application points to that file, I am sure there is a way to put those settings in a grid, but probably you will lose the capability of "showing settings based on Role".

Thanks


A lot of this comes down to preference, what settings you're talking about, when you need access to the settings, and how often they'll change.

Generally, I try and keep my web.config & app.config pretty small. Settings for infrastructural things (e.g. modules to load, connectionstrings, log settings, ORM settings, etc) go in there. Anything that I really need or want to have access to on App_start or in my Main() method, basically.

Anything more complex, or that's applicable to less of the application, etc, I generally don't put in the config files, but instead either have settings objects which I inject through my IoC container, or else pull them from a database.


I prefer option 1, as it makes deployments easier, as each environment can have different configurations, yet you're still able to do a xcopy deploy, as settings aren't stored in the web.config.


I would suggest putting the configuration in the database and then retrieving it based on the application. You can also write a single XML that contains different configurations and load it on the datagrid etc..This way management of the configuration becomes easier, because you have a single file to maintain.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号