How to read Telerik appSettings from an external file
HOW TO
Load the Telerik appSettings flags from an external file.
DESCRIPTION
The UI for ASP.NET AJAX controls provide [a lot of switches and settings you can set from the appSettings section in the web.config](/devtools/aspnet-ajax/getting-started/installation/web-config-settings-overview#control-properties-you-can-set-from-the-webconfig. In some cases you may want to declutter the web.config file and read these settings from a separate file. This can even facilitate deployment and testing, especially if you also use your own flags in the appSettings section.
SOLUTION
ASP.NET allows you to import sections of the web.config file from an external file that is under the same folder. To do this:
- copy the
appSettings
section in your desired configuration file (e.g., in ~/App_Data/myAppSettings.config) - remove the contents of the
appSettings
section - set the
configSource
attribute of theappSettings
tag to point to the external file (configSource="App_Data\myAppSettings.config"). Note the backslash that denotes a physical path.
You can find attached a small example below. Just add the Telerik assemblies to the ~/bin
folder.
SEE ALSO
- MSDN: Using External Configuration Files
- How to encrypt the Telerik appSettings keys
- Telerik Control Properties You Can Set From the web.config
A sample project that demonstrates the approach can be found attached here: