Search This Blog

Friday, February 18, 2011

Nice way to store values at web application and web levels

I came across a nice way to store values at the web application and web levels for whatever needs you may have. In my case I need to store some global settings. To do this I was storing those in a list and when using those in application it was a long process. So after discovering these available property bags I was interested in trying to store existing values there.

SPWebApplication webApp = (SPWebApplication)properties.Feature.Parent;
webApp.Properties.Add("Rule", "{FileName}");

// reference property later
string rule = webApp.Properties["Rule"];

Similarly you can use SPWeb property bags.

Thanks

No comments:

Post a Comment