Overriding Individual Application Settings

You may have the situation where you want to be able to override application settings for a .NET application only for your particular instance of the application. This is often the case when you are developing the application, you need to change only the local settings, but you don't want to change the config file that is part of the project and under source control. Here we'll explain the solution that .NET provides but isn't so well known.
We'll use the ASP.NET web.config file for this example.

First, you place the attribute file="user.config" in the web.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<appSettings file="user.config">
               <!-- your application settings -->
	</appSettings>
	<system.web>
		<!-- standard asp.net configuration nodes -->
	</system.web>
</configuration>
This will point to the named file for application setting overrides. Then you can create the user.config file in the application directory to hold your personal overrides for the default application settings. The file should look like this:

<appSettings>
	<add key="key" value="value" />
</appSettings>

Note that appSettings is the root node. The user.config file does not have to exist. .NET will just ignore a missing file and use the default values in web.config.

If you do create this file make sure you do not put it into the project (and, thus, source control) so as to avoid overwriting individual's settings.

This solution can be found in the MSDN article: Team Development with Visual Studio NET and Visual SourceSafe - Chapter 4: Managing Dependencies which has lots of other details that are helpful to know if you are building software in a team environment.

Where to Next?

Wonder where to go next? You can post a comment on this article.

Doc ID 366
Full URL https://imar.spaanjaars.com/366/overriding-individual-application-settings
Short cut https://imar.spaanjaars.com/366/
Written by Imar Spaanjaars
Date Posted 03/03/2005 23:55
Date Last Updated 03/05/2005 14:30
Date Last Reviewed 05/24/2006 20:24

Comments

Talk Back! Comment on Imar.Spaanjaars.Com

I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.

When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.

If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the Doc ID of the document.

(Plain text only; no HTML or code that looks like HTML or XML. In other words, don't use < and >. Also no links allowed.