Beating the web.config 250k limit

spanner_iconIn this blog post, we will talk about how you can beat the web.config 250k limit by splitting up your web.config into a number of subfiles.

Not only can the discussed method be helpful in beating the 250k limit, it can also help when swapping out config’s based on environments, as an example you could have one config setup with a connection string for your development setup and another for your production environments.

Splitting your web.config

To help us split up our config files we will be using the configSource option within the web.config file, below is a very basic web.config which has it’s own file setup for the connection string:

<?xml version='1.0' encoding='utf-8'?>
<connectionStrings configSource="connections.config"/>

Now as well as the web.config file, we also have a file named connections.config, this is where the connection string details are stored, an example of this can be seen below:

<?xml version="1.0"?>
<add name="SiteSqlServer" connectionString="Data Source=HOSTNAME;Initial Catalog=DATABASENAME;User ID=USERLOGIN;Password=PASSWORD" providerName="System.Data.SqlClient"/>

The above method can be used for the other sections of the web.config file as well.

Rate this post 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

This entry was posted in General, Tips & Tricks, Tutorials, Windows, ASP & .NET and tagged . Bookmark the permalink.

Leave a Reply

Please DO NOT use this form to submit support requests, all information submitted will be PUBLICLY VISIBLE.

Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.