Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

.NET Handling of Large Size Config File Issues

0.00/5 (No votes)
4 Dec 2014 1  
This is a very basic ASP.NET tip about how to manage multiple Config files on one web application by dividing the specific Config settings to multiple Config files.

Introduction

This is a very basic ASP.NET tip about how to manage multiple Config files on one web application by dividing the specific Config settings to multiple Config files.

Background

While developing the web application, a developer prefers to keep Configuration or setting parameters in Config file. The config file size can be too big due to more configuration sections like appSetings, configSections, connectionStrings, services related sections, logging sections, etc. In case of Enterprise Library Blocks, all of the configuration settings reside in .config file. This easily exceeds the config file default size limit of 250 KB. This throws the exception "Cannot read configuration file because it exceeds the maximum file size".

Solution

The solution for this issue is splitting of config file. Using this, we can specify certain sections of your web.config reside in a separate .config file. So you could have a connectionStrings.config file containing your connection strings or appSettings.config file for your appSettings section of web.config.

Below, we have Main Config file where we have mentioned the Config source to different configuration files.

ConnectionStrings.config

Appsettings.config

Points of Interest

  • Separate files can result in a more logical and modular structure for configuration files
  • Easy to manage
  • Settings in include file can be managed or changed at runtime without any impact

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here