Did you know that you can move sections of your Web.config file into other
files? Whether it's to keep things tidy or simply to make it easier
to find the settings you change often, it's easy to do and yet few people
even realize you can.
The magic that makes this possible is the configSource attribute. It was added in
.NET 2.0 and its value indicates the name of the file that contains the section
that we're moving to another file. It's probably easiest to illustrate via
a simple example. A normal connectionStrings section in Web.config might
look something like this:
See... it really couldn't be much simpler. Now you can play with your connection
strings as much as you want without fear of messing up any other settings in
your Web.config file.
Oh... and just because I only showed you how to move the connectionStrings section,
don't think that it stops there. You can just as easily move any section you want
to an external file: appSettings, mailSettings, urlMappings, etc.
If you have a tip you would like to submit, please send it to:
webmaster@asp101.com.