In The Mix

As a SharePoint architect I have the business behind me and the Developers and IT Pro on my shoulders.

Where should I keep my Configuration May 29, 2010

Filed under: SharePoint — fmuntean @ 8:15 pm

This is one of the though questions when talking about custom SharePoint applications. Out of the box there is no specialized service to provide configuration API for your application. However being a platform SharePoint  provides many places that you can use to keep your configuration. Let’s see what are your options and some pro and cons about each.

1. Web.Config:

If you are an ASP.NET developer then usually your first place to use would be the web.config. The problem is that most likely you production SharePoint uses multiple servers and manually changing the web.config is a nightmare and unadvisable. The only acceptable way to change the web.config is to use SPWebConfigModification class and a feature to install and uninstall your modifications.

2. SPPersistedObject.Properties:

There are many places inside the SharePoint Object Model that you can use to store your configuration. All the objects derived from the SPPersistedObject have a Properties HashTable where you can store configuration. The exist at all levels: SPFarm, SPWebApplication, SPWeb, SPFeatureDefinition just to name a few. At the same time you can create your own Persisted Object that you can use as your configuration object as part of the Farm.

3. XML File:

There is nothing to stop you to load a configuration file in SharePoint and load it inside your application. However you might want to encrypt this file if you have sensitive data that you don’t want to be in clear.


While for all other places you will need to build some kind of UI to deal with setting the configuration  values by using SharePoint Lists you get that for free. To read the values just use CAML Queries from your code.