---
title: Settings
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

List of examples:

## Dependency injection

### Initialize required services

```csharp
// 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](#toc)

### Get the values of database settings

```csharp
// 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](#toc)

### Get the values of application settings

```csharp
// Gets the value of the "CMSApplicationName" key from a configuration provider (e.g., appsettings.json)
string applicationSetting = configuration["CMSApplicationName"];
```

[> Back to list of examples](#toc)

### Set the values of settings

```csharp
// 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](#toc)
