Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 days ago.
Is there a way I can create a blah.config file in asp.net, and access the name/value pairs of nodes the same way you access items in in a regular web.config file?
(the idea is to not have to write any custom code for this).
Chris shows one way to "externalize" part of your configuration. That works fine for certain scenarios. If you need more, you'll need to dig in a bit deeper.
For that, you should definitely check out Jon Rista's three-part series on .NET 2.0 configuration up on CodeProject.
- Unraveling the mysteries of .NET 2.0 configuration
- Decoding the mysteries of .NET 2.0 configuration
- Cracking the mysteries of .NET 2.0 configuration
Highly recommended, well written and extremely helpful! He shows how to create and use custom configuration sections, and goes on to explain how to use your own blah.config
instead of or in addition to standard .NET config files.
Marc
Use the "file" attribute of the appSettings block, like so:
<appSettings file="user.config">
<add key="Test1" value="Generic1" />
<add key="Test2" value="Generic2" />
</appSettings>
Further explanation available here.