views:

57

answers:

2

Having built myself a decent website using ASP.NET MVC, I'm about to build an "Admin Panel" for users in the "Admin" Role to control the website with. Specifically, the website that I've built is an internal site for an enterprise and it consists of a bunch of mini web-apps, each of which need to be configured and/or tweaked from time to time.

Is Web.Config the appropriate file to store these application settings?

Should it be in a separate XML file?

A DB Table (or set of tables)?

Currently, I have no DB available to me, but perhaps at a later date I will. Currently, I'm inclined to create an XML file and store values there. Is this a reasonable approach? Or am I missing something obvious on how to do this?

EDIT: Ok, here's my abstraction layer (Interface):

public interface IAppSettings
{
 IQueryable<string> GetValues(string component, string setting);
 void SetValues(string component, string setting, List<string> values, bool append);
}

I figure I can read/write to Web.Config, another XML, or a DB this way.

What do you think?

+1  A: 

I would recommend you a db. Writing to files in a multi-user/multi-threaded application could be challenging and problems could arise if you don't synchronize the access to those files, not to mention transactional access if you ever needed such. There are some lightweight NoSQL databases which could be extremely useful and easy to setup.

Whatever you choose make sure to create abstractions over the data access layer so that you could easily switch later to another method like a SQL database if you will (after trying a NoSQL database you probably won't will :-)).

Darin Dimitrov
Good call on the abstraction layer. I was thinking the same thing: Write a good Interface definition. I recently stumbled upon the "appSettings" area of Web.Config, which seems reasonably suited to handling and storing application settings that don't change very frequently. So I think my short-term approach is to write a good Interface definition and then implement a concrete class which implements that interface and utilizes the web.config file to store my admin data (for the time being.) Hopefully, I can convince the IT department to give me my own MS-SQL database soon.
Pretzel
+1  A: 

The question to ask here is, in general, is this a set of settings that will change with the codebase or be changed by users? If it is the former, XML is the way to go -- it can easily be version controlled with the code. If users are changing it then a database is a better option.

Wyatt Barnett
These settings would likely be changed by a very small handful of users in the "Admin" role. (I'm thinking 3 or 4 people at most.) And even then, the settings would likely only be tweaked once in a while (maybe once a month, by 1 of the admins.)
Pretzel