How To Add Custom Settings / App Settings In Sitecore

When building a website you will inevitably need to store configuration data somewhere. In today’s post, I’m going to cover the options available to you when you use Sitecore.

Web.Config

As Sitecore is a .NET application you can always use the app settings section in your web.config.

<appSettings>
<add key="SettingName" value="true" />
</appSettings>

Which you can then access in code like this:

var value = ConfigurationManager.AppSettings["SettingName"];

It’s generally advised to try and keep your web.config as mean and lean as possible. If you want to upgrade your Sitecore, then you have to merge manually your web.config.

SiteCore Setting

Sitecore also provides an easy API to write your own APP settings file. This can be really useful if you want to deploy your site in different environments. To create your own Sitecore App settings file, first, create a new file in \App_Config\Include. You can call it whatever you like. I normally use ProjectName.Settings.config.

In the file you can add in custom settings by using the following convention:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<settings>
<setting name="SettingName" value="true"/>
</settings>
</sitecore>
</configuration>

We can access these settings like this:

var value = Sitecore.Configuration.Settings.GetSetting("SettingName")

If you have any issue with your settings, you can always check Make sure the Sitecore config page to make sure Sitecore knows about your setting. To access use the following in your web browser, www.website.com/sitecore/admin/showconfig.aspx.

If you want to you can also use the Sitecore API to get access to normal App settings by using the following snippet:

Sitecore.Configuration.Settings.GetAppSetting()

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

More Posts

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *