I guess we've all been there. We want to store some settings for our WebPart / List / Custom App / Timer Job. Where do we save it?
Multiple options exist:
- The various existing property bags (
SPList
,SPListItem
,SPWeb
,SPWebApplication
,SPFarm
)SPPropertyBag
- A hidden "settings" list
These options are limited as they relate to only a specific site collection. With a dynamic URL, more site collections and maybe a timer job not knowing where the settings reside (you don't want to hardcode an URL).
Web Application / Farm wide settings can be stored in:
web.config
SPPersistedObject
Both have their problems: web.config
is per Web Application, not per Farm. Timer Jobs don't have it too easy to access the web.config
s as they don't run in w3wp
, but in owstimer
.
The persisted object has the problem that you access the Farm config db with the current web application pool account. That account typically doesn't have read / write access to the Content DB. Giving the account access would mean opening the SharePoint config DB to any code running RunWithElevatedPriviliges
.
What are your suggestions for saving farm wide configuration data for e.g. timer jobs or a "global web application spanning navigation"? My last idea is a custom service application with a custom database, but that somehow seems kind of over-the-top.