How do I Access Sitecore settings Programmatically?

All the settings of the Sitecore are stored in the config files. Sitecore consists of web.config which stores all the configuration information. Addition to this Sitecore has many config files which are stored in the App_Config/Include folder. Most of the time’s developer place the config files to override or patch the Sitecore functionalities. So how do you Access Sitecore settings Programmatically which is present in the config file?

Access Sitecore settings Programmatically

During the runtime, Sitecore combines all these config files into one single web.config file. Hence at the runtime, we can access any of these config file settings programmatically.

To verify the web.config file Sitecore provides an admin page.

URL : http://myurl/sitecore/admin/showconfig.aspx 

The above URL will combine all the configs from App_Config/Include and displays single config file.

All the settings listed in the config file can be accessed at run time using the below code.

var mySetting=Sitecore.Configuration.Settings.GetSetting("SettingName");

Access Data Folder in Sitecore Programmatically

string dataFolder = Sitecore.Configuration.Settings.DataFolder;


Leave a Reply

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

You May Also Like
XOR in Python

XOR in Python

XOR Operator in Python is also known as “exclusive or”  that compares two binary numbers bitwise if two bits are…
How To

How to configure Git proxy?

If you are working in the corporate company all the internet requests usually goes through the corporate firewall.…