Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.Config vs Database Settings table

When you have a system of multiple application, web services and windows services, 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

like image 1000
Costa Avatar asked Jan 09 '11 13:01

Costa


People also ask

Is it better to keep configurations in config file or database?

Multiple versions may require different key values. The bottom line is that if it's a large scale distributed environment, database is the way to go unless you have automated config file management system in place.

What is the difference between web config and machine config?

The web. config files specify configuration settings for a particular web application, and are located in the application's root directory; the machine. config file specifies configuration settings for all of the websites on the web server, and is located in $WINDOWSDIR$\Microsoft.Net\Framework\Version\Config.

What is Web config used for?

The Web. Config file is used to configure Oracle Web Application functionality. This file is typically installed in the c:\Inetput\wwwroot\WebApp directory. This section describes settings in the top-level WebApp Web.

Is Web config mandatory?

Yes, we can run an ASP.NET web application without web. config file but without in debugging mode. If we don't configure any settings in web. config file then it consider machine.


2 Answers

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.

like image 79
Paul Avatar answered Sep 23 '22 12:09

Paul


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.

like image 29
Bravax Avatar answered Sep 25 '22 12:09

Bravax