Wednesday, November 25, 2009

Make managing config files easier with configSource

If your config files start growing too big, you can split them up into smaller pieces by using the configSource attribute.

For example, if you want to extract your WCF services configuration to a dedicated configuration file, place the following in your web.config:

   1:   <configuration>
   2:      ...
   3:      <system.serviceModel configSource="services.config" />
   4:      ...
   5:    </configuration>


Create then a separate services.config file with the following structure:

   1:  <system.serviceModel>
   3:  <!-- Place your service settings here -->
   5:  </system.serviceModel>


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.

No comments: