Moving configurations to database

October 24, 2011 Digital Experience

With the release of Sitefinity 4.0 we have moved from storing Sitefinity related configurations in web.config to providing our on configuration persistence in the Sitefinity config files.This is the default setting for storing configurations and all of your settings are stored in the ~/App_Data/Sitefinity/Configuration/. When we released our support for multiple instances on Windows Azure we had to allow users to store configurations in the database, otherwise your Azure instances would not run with the same settings if you made any changes in the Administration -> Settings area of Sitefinity.This feature allows you to set up your Sitefinity website to store all configurations in the database, it can be used on non-Azure projects. Here is how you can set up database configurations storage:

1) Create a new project with the Sitefinity Project Manager. Instead of opening the project in the browser to set it up, open it in Visual Studio.

2) After you have opened the project in Visual Studio and go to your web.config file. Uncomment the telerik configuration section:

<sectionGroup name="telerik">
  <section name="sitefinity" type="Telerik.Sitefinity.Configuration.SectionHandler, Telerik.Sitefinity" requirePermission="false" />
</sectionGroup>

Set up your database storage mode:

<telerik>
  <sitefinity>
    <!--<environment platform="WindowsAzure"/>-->
    <sitefinityConfig storageMode="Database" />
  </sitefinity>
</telerik>

After this operation you can run the project in the browser and instantiate it. It will create a connectionString setting in your web.config which will point to your database. Please note that for this operation you need to have the website identity be able to write/modify the web.config file. When the website is created there will be only two files in ~/App_Data/Sitefinity/Configuration. Those files will be ProjectConfig and SecurityConfig.

If your environment does not allow writing to the web.config file you can fist set up the project and then go to setting configurations to be stored in database. If you choose this approach, you will have the a few files in ~/App_Data/Sitefinity/Configuration that are created when the project is instantiated. Those files contain default configurations created when each project is ran for the first time and are necessary for the project's proper operation. You can eliminate the DataConfig file by moving your connection string to the web.config file as Vladi has outlined in this forum post.Any further configuration change will be persisted in the database.

This approach is very useful in a number of scenarios, for example setting up the project in NLB environment and using different file systems for each load balanced server. You can also prevent exposing SMTP settings in the config files, LDAP connection strings as well as other sensitive information.

The Progress Team

Read next How Hybrid Cloud is Driving Load Balancing Strategies—And Why a Unified Approach to Load Balancing Matters