Wonder
Wonder

Reputation: 1020

Storing web site configuration

I'm looking for a place to store the configuration of my web site that will be changed throught site's admin panel (like choosing theme, changing home page title etc). As I know web.config is read-only, and for sure I don't want to use DB for this. So what is the standard method to solve this?

Upvotes: 0

Views: 267

Answers (3)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038810

and for sure I don't want to use DB for this

Well, you don't have many choices left. You could always use files but in a multithreaded environment such as an ASP.NET application you will need to synchronize the access to them to ensure that 2 threads are not trying to write to the file at the same time or that while one thread is writing to the file another one is not reading from it. You could use a ReaderWriterLockSlim for that. As far as the format of this file is concerned, you could use just anything you feel comfortable with: CSV, XML, JSON, even binary serialization if you want.

Upvotes: 5

Tom Chantler
Tom Chantler

Reputation: 14941

If it's just for site administration, setting application wide settings (such as title) then it's fine to store in a file and XML or JSON is perfectly okay as long as you somehow make sure the file cannot be accessed by two people at once (preventing more than one site admin from logging in at once removes this issue).

If you want the users to be allowed to choose their own theme, time zone, etc, then you'd be better off storing this in the database.

Upvotes: 1

gdoron
gdoron

Reputation: 150253

If you don't want to use DB for sure for some reason.

I think XML is the best option for saving configuration. just like the web.config.
Just make sure to use lock when you access this file, so you won't get unsynchronize disasters...

Upvotes: 2

Related Questions