473,466 Members | 1,366 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Multiple config files

I quite like to store variables in the web.config file. However it can make
the web.config messy and make deployment fiddly. Is there any way of have
multiple web.config files - one with the major stuff and one with minor
stuff such as my variables which can differ from development to production.
Or alternatively is there some kind of tool to make the deployment smoother?
Regards, Chris.

Jun 27 '08 #1
2 1673
>I quite like to store variables in the web.config file. However it can make
>the web.config messy and make deployment fiddly. Is there any way of have
multiple web.config files - one with the major stuff and one with minor
stuff such as my variables which can differ from development to production.
Or alternatively is there some kind of tool to make the deployment smoother?
You can define a "configSource=........" attribute for just about
every section in your web.config, to "externalize" your config
settings to separate files:

<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
...
</pages>
</system.web>
<system.serviceModel>
<bindings configSource="serviceModel_bindings.config"/>
<client configSource="serviceModel_client.config"/>
.......
</system.serviceModel>
<connectionStrings configSource="connectionStrings.config" />
........
</configuration>

Those external config files now simply contain the section that you
would normally have directly in your web.config, e.g.

connectionStrings.config:

<?xml version="1.0" encoding="utf-8" ?>
<connectionStrings>
<add name="default" connectionString="........"/>
</connectionStrings>
That alone can make your web.config a lot more readable right there -
and it's totally built in, no extra custom code needed - nada.

Hope this helps.
Marc
Jun 27 '08 #2
I'll have a look at that. It looks like exactly what I'm looking for.
Cheers.

"Marc Scheuner" <no*****@for.mewrote in message
news:gn********************************@4ax.com...
I quite like to store variables in the web.config file. However it can
make
the web.config messy and make deployment fiddly. Is there any way of have
multiple web.config files - one with the major stuff and one with minor
stuff such as my variables which can differ from development to
production.
Or alternatively is there some kind of tool to make the deployment
smoother?

You can define a "configSource=........" attribute for just about
every section in your web.config, to "externalize" your config
settings to separate files:

<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
...
</pages>
</system.web>
<system.serviceModel>
<bindings configSource="serviceModel_bindings.config"/>
<client configSource="serviceModel_client.config"/>
.......
</system.serviceModel>
<connectionStrings configSource="connectionStrings.config" />
.......
</configuration>

Those external config files now simply contain the section that you
would normally have directly in your web.config, e.g.

connectionStrings.config:

<?xml version="1.0" encoding="utf-8" ?>
<connectionStrings>
<add name="default" connectionString="........"/>
</connectionStrings>
That alone can make your web.config a lot more readable right there -
and it's totally built in, no extra custom code needed - nada.

Hope this helps.
Marc
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vlad | last post by:
Is there any way to install multiple instances of the same windows service designed with VS.NET 2003? I tried copying the binaries into a separate folder and then copying registry entries for the...
1
by: RK | last post by:
Hi I am working on C# application, where in I may require just one app.config for the C#.NET solution with multiple windows application projects. I know one web.config can be used for multiple...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
6
by: Andrew Connell | last post by:
I have an app where I want virtually everything password protected/secure except for a single directory. That directory handles some custom authentication and contains my login form, but also some...
5
by: BPearson | last post by:
Hello I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to...
2
by: Sam | last post by:
Hi All, I have a solution which consists of multiple projects and each of these projects has their own app.config file. The problem is that all of my projects in the solution pull keys from the...
1
by: herbert | last post by:
In VS.2005 a Windows Service can have an app.config file. A class library can also have an app.config file. Now if my Windows Services uses three class libraries, each of it coming with its own...
3
by: | last post by:
I'm seeking (probably basic) guidance on the right way to split a large site that's supposed to represent one domain(mydomain.org) into many small VS.NET projects, and how to avoid issues with...
3
by: =?Utf-8?B?QXZpc2hheSBCZW4tWnZp?= | last post by:
Hi, I have an application that I am encrypting the connection strings on the first run of the application. I am using clickonce to deploy the application, so this was a good solution as the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.