For those of you not familiar with the PropertyBag, it is a place to store metadata or properties for your web sites in SharePoint. Much like the term "SharePoint," "PropertyBag" actually can refer to two things on the SPWeb object:
Properties - a SPPropertyBag object
AllProperties - a hashtable
I've always used Properties when setting metadata for web sites but I've heard lots of people lately saying that AllProperties is the better place to put things. The difference is Properties actually returns a subset of AllProperties. As long as you are consistent with how you are adding/accessing the metadata, you can use either one.
So - why would you use the property bag?
- Add additional context for your site - if you are on a project site, add the matching id from your LOB systems. Web Parts can then read that data, connect to your LOB system and return relevant information.
- In SharePoint, each web doesn't have a web.config to put configuration values in. The property bag is a nice place to store configuration variables.
So - how do I use the property bag?
- There is no out of the box web interface to manage property bag values on a SharePoint web site
- Thanks to Corey, I now know how to manage the property bag in SharePoint Designer! I can't believe I haven't seen this before:
- You can use PowerShell to display properties:
and update properties:
- Obviously if you can update the PropertyBag in PowerShell, you can also update them via Web Part, Feature Receiver, etc...