My new blog

My blog has moved to www.davehunter.co.uk/blog see you there.

Wednesday 18 July 2007

Adding web.config settings to you WSS or MOSS site

This article describes how to add web.config settings automatically to your new web applications under WSS V3 and SharePoint 2007.

You need to create a file in the format of webconfig.[name].xml, copy the file to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\CONFIG folder and the settings in the file will be merged with the web.config file on any new web application. Unfortunately this only works for new web applications, if you put the file in the config folder no changes will be applied on existing web applications.

The example below adds a key to the appSettings and a database connection string to the connectionStrings section.

<?xml version="1.0" encoding="utf-8" ?>
<actions>
<add path="configuration/appSettings">
<add key="MyFilePath" value="C:\temp\path\" />
</add>
<add path="configuration">
<connectionStrings />
</add>
<add path="configuration/connectionStrings">
<remove name="MySqlServerConnection" />
<add name="MySqlServerConnection" connectionString="server=[server];database=[db];Integrated Security=SSIP;" providerName="System.Data.SqlClient" />
</add>
</actions>

No comments: