Auto-storage mode of configurations
Overview
Auto-storage mode is the default and recommended configuration storage option. It is a hybrid mode that stores configuration files on both the file system and the database (in table [sf_xml_config_items]).
- Environment configurations that are part of the system setup are stored in the file system.
They are part of the deployment process of the web application and you distribute them as files between different environments.
Such configurations are the Advanced settings of Sitefinity CMS. - Application settings that are part of the Sitefinity CMS website and are modified runtime are stored in the database.
Turn on Auto-storage mode of configurations
When Sitefinity CMS uses FileSystem storage mode, you can switch to Auto-storage mode.
IMPORTANT: Once you switch to Auto-storage mode, you cannot switch back to any different configuration storage option.
To turn on Auto-storage mode of configurations, perform the following:
- Open you
web.configfile. - Make the following transformations:
XML
<!--Uncomment the following section group:--> <sectionGroup name="telerik"> <section name="sitefinity" type="Telerik.Sitefinity.Configuration.SectionHandler, Telerik.Sitefinity" requirePermission="false" /> </sectionGroup> <!--Uncomment the following section:--> <telerik> <sitefinity> <environment platform="WindowsAzure"/> <sitefinityConfig storageMode="Database" /> </sitefinity> </telerik> <!--Delete the following:--> <environment platform="WindowsAzure"/> <!--Set the storage mode to Auto in the following way:--> <sitefinityConfig storageMode="Auto" /> - Save and close the
web.configand restart the application.
From this point on, the configuration files will be stored on both the file system and the database. In Auto-storage mode, the system makes the best decision where to store the configurations depending on the context.
When the system is in Auto-storage mode, you can restrict the modification of the file system configurations. For more information, see Read-only mode of configurations.
IMPORTANT: You must not remove existing configuration files from the project's
~/App_Data/Sitefinity/Configurationfolder, because Sitefinity CMS continues to use them to read the default values. Only new changes are written to the database.
Explicitly save configurations on the file system in Auto mode
When the system is in Auto-storage mode, if you want to save a configuration intentionally on the file system, you can use one of the following methods:
- The
FileSystemModeRegionin the following way:C#using Telerik.Sitefinity.Configuration; using Telerik.Sitefinity.Modules.Pages.Configuration; namespace SitefinityWebApp { public class SaveConfigsToFileSystem2 { public void SaveConfigsWithModeReagion() { using (new FileSystemModeRegion()) { var configManager = ConfigManager.GetManager(); var myConfigSection = configManager.GetSection<ToolboxesConfig>(); ConfigManager.GetManager().SaveSection(myConfigSection); } } } } - The
SaveSectionoverload method:C#using Telerik.Sitefinity.Configuration; using Telerik.Sitefinity.Modules.Pages.Configuration; namespace SitefinityWebApp { public class SaveConfigsToFileSystem { public void SaveConfigsToFileSystemAutoStorage() { var configManager = ConfigManager.GetManager(); var MySection = configManager.GetSection<ToolboxesConfig>(); ConfigManager.GetManager().SaveSection(MySection, true); } } }