I have a project for which we are extending some functionality from an existing client into a web portal in ASP.NET 2.0. The client is windows forms based (in .NET 2.0). It has some settings that are kept in the Project > Properties > Settings.settings system, including a generated settings.Designer.cs file. This file provides nice automatic wrappers for each of the settings.
In trying to set up the website I have been frustrated by an apparent lack of parity for this feature. I have a web.config, and it can have an section. This means access via code with strings, for example:
WebConfigurationManager.AppSettings["mySetting"];
I can even have the settings refer to another file this way, affording a little abstraction, and easier check-ins to source control:
<appSettings configSource="web.settings.config"/>
but ultimately this lacks some of the functionality of the client projects settings system.
Particularly I would very much like these features if at all possible:
- Autogenerated accessor class (for convenience, intellisense..)
- Convenient
- Strongly Typed
- Provides Intellisense
- Code will not compile against typos/mistakes in settings names
- Easy Interface
- The settings.Settings before provided a nice grid
- All options represented
- Showed dropdown choices for certain options
- Don't have to edit XML
- Can't fat-finger an angle bracket
I know that it would be possible to create a class that wrapped these, but it would not stay in sync with the settings automatically, and would have to be manually edited on any change. It would provide some of the above however.
Can I get parity with the project settings like we do in our client?
What is the best way to manage settings for an ASP.NET 2.0 website?