AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    Administration interface basicsDevelopers and adminsBusiness usersChangelogGlossary
  • Guides
    Welcome to Xperience by KenticoAdministration interface basicsCustomer journeysDigital marketingConfigurationDevelopmentArchitectureUpgrade to Xperience by Kentico
  • Training
    For AdminsFor Business usersFor DevelopersFor Solution architects
  • API Examples
    ConfigurationContent managementDevelopmentDigital marketing
  • Changelog
    Documentation updatesSecurity advisories
  1. Home
  2. Configuration
  3. Settings

Settings


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

List of examples:

  • Dependency injection
    • Initialize required services
    • Get the values of database settings
    • Get the values of application settings
    • Set the values of settings

Dependency injection

Initialize required services

C#
// Initializes all services and provider classes used within
// the API examples on this page using dependency injection.
private readonly ISettingsService settingsService;
private readonly IInfoProvider<SettingsKeyInfo> settingsKeyInfoProvider;
private readonly IConfiguration configuration;
private readonly IConversionService conversionService;

public SettingsServices(ISettingsService settingsService,
                IInfoProvider<SettingsKeyInfo> settingsKeyInfoProvider,
                IConfiguration configuration,
                IConversionService conversionService)
{
    this.settingsService = settingsService;
    this.settingsKeyInfoProvider = settingsKeyInfoProvider;
    this.configuration = configuration;
    this.conversionService = conversionService;
}
> Back to list of examples

Get the values of database settings

C#
// Note: Find the code names of individual settings keys in the CMS_SettingsKey table

// Gets the value of the "Asset allowed extensions" setting
string assetAllowedExtensions = settingsService["CMSMediaFileAllowedExtensions"];

// Gets the value of the "Enable Continuous Integration" setting
bool continuousIntegrationEnabled = conversionService.GetBoolean(settingsService["CMSEnableCI"], false);

// Gets the value of the "Event log size" setting for the current site
int eventLogSize = conversionService.GetInteger(settingsService["CMSLogSize"], 60);
> Back to list of examples

Get the values of application settings

C#
// Gets the value of the "CMSApplicationName" key from a configuration provider (e.g., appsettings.json)
string applicationSetting = configuration["CMSApplicationName"];
> Back to list of examples

Set the values of settings

C#
// Adds additional extensions to the list of allowed extensions
SettingsKeyInfo allowedExtensionsSettingsKey = settingsKeyInfoProvider.Get("CMSMediaFileAllowedExtensions");
allowedExtensionsSettingsKey.KeyValue += ";tiff";
allowedExtensionsSettingsKey.Update();

// Disables the Continuous Integration feature
SettingsKeyInfo ciSettingsKey = settingsKeyInfoProvider.Get("CMSEnableCI");
ciSettingsKey.KeyValue = "False";
ciSettingsKey.Update();

// Sets the maximum event log size to 30
SettingsKeyInfo logSizeSettingsKey = settingsKeyInfoProvider.Get("CMSLogSize");
logSizeSettingsKey.KeyValue = 30.ToString();
logSizeSettingsKey.Update();
> Back to list of examples