Using configSource to split configuration files
As Nikhil Kothari writes in his blog, he's started to use the configSource attribute to split configuration files into smaller pieces.
For example, here is how he exports the profile
configuration into a dedicated configuration file.
This
is web.config:
...
<system.web>
...
<profile configSource="profile.config"
/>
...
</system.web>
...
This
is profile.config:
<profile>
<properties>
<add name="Name"
type="String" />
<add name="Age" type="Int32"
/>
</properties>
</profile>
Make sure you use .config as the extension of your files so
they cannot be served to the browser. Avoid .xml for example
or your files can be available to prying eyes.
I've been using this feature for my web sites for a while.
This allows having a unique web.config file, and separate
sub-files for things that are different between the
development machine and the hosting environment. For
example, I have different connectionStrings.config and
smtp.config files for the two environments. The benefits:
the web.config file is smaller and hence easier to read, and
you don't need a complete web.config file for each
environment.
