Tuesday, November 16, 2004

User.Config File

For those of you who wish there was a nice way to modify a web site project and not have to worry about changing workstation specific configuration settings in the web.config file (like datbase connection strings, etc.) you can use the file="user.config" attribute of the <appsettings> tag.

You can do the following in web.config:
<configuration>

<appsettings file="user.config">
<add key="Key" value="Value" >
</appsettings>
</configuration>
Then, create a file called user.config in the same folder as web.config, and paste the following code. Notice that there is no <configuration> tag:
<appsettings>

<add key="Key" value="Override value" >
<appsettings>

Do not add the user.config file to the project. If there is no user.config in the same folder, then the web.config settings are used.

MSDN:Web Projects Source Control Integration In VisualStudioNET


No comments: