views:

49

answers:

2

In my experience, web.config files are widely reviled. In particular, I have found them difficult to manage when you have multiple environments to support, and fiddly to update due to the lack of validation at update-time and the verbosity of XML.

What are the alternatives?

+3  A: 

How long has ASP.NET been in existence; how many production web sites are using it?

They're almost all using web.config, as it comes, out of the box. They can't be "reviling" it too much.

That said, look at the new features of ASP.NET in .NET 4.0, including configuration-specific web.config files, and xml-based transformations of web.config that permit environment-specific web.config versions to be generated at deployment time.

You may revile that a little less.

John Saunders
You can use some of the tasks in http://msbuildtasks.tigris.org/ with ASP.Net < 4.0 to achive the same transformations. A must imo.
Mikael Svenson
+1  A: 

I strongly disagree with your assertion that web.config files are "widely reviled." In my experience, they're easy to maintain and manage, and in some cases are the only place you can put configuration data.

It's worth noting that VS2010 supports per-build configuration web.config transforms. I have a web.config, web.debug.config, and web.release.config. The debug and release files override the connection strings specified in web.config and replace them with the correct strings, for my debug and production SQL Servers, specifically. I'm also using this to make some AppSettings values config-specific.

Since you can add a build config for as many different targets or configurations as you require, I don't see why you'd feel the need to reinvent the wheel by devising another repository.

That said, you can use just about any repository for whatever data you want to store. A database, text config file of the format of your choice, encrypted image, or what have you.

I'm tempted to ask your name and employer so that, if you wind up going this route, I won't wind up maintaining such ill-conceived code in the future.

David Lively
Yes, the VS2010 per-build web.config transforms sound like they will solve many of the issues I have seen in previous projects I have worked on. No need to ask my name - see my username. I do feel, however, that XML configuration files are error-prone and difficult to read due to their verbosity; I'd prefer a simpler list of key-value pairs in most cases.
Ben Aston
I have a check-in task that validates the .config files. You should really have something that does this in place, anyway.
David Lively