Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

SPWeb:: Properties

Posted by Paul on July 2, 2014

While doing real-world programming, we often require to store some values in the site.

For example:

  • Storing the name of user who created the site
  • Storing the type of site


We can achieve this through Properties property of SPWeb.  This returns a collection of type SPPropertyBag.

IIS Reset Problem

Over the forums I have found that certain people says property bag is cleared on IIS Reset.

I have tested this & In my observation the property values are retained.

class Program
       static void Main(string[] args)
           using (SPSite site = new SPSite(“http://hpvm”))
               SPWeb web = site.AllWebs.Add(“new”);
               web.Properties[“key”] = “value”;
               Console.WriteLine(“Created property ‘key’ with ‘value'”);

           Console.WriteLine(“Resetting IIS”);

           using (SPSite site = new SPSite(“http://hpvm”))
               SPWeb web = site.AllWebs[“new”];
               string value = web.Properties[“key”];
               Console.WriteLine(“Stored value is:” + value);

You need to create a new console application, add references, change build to 64 bit for testing the application.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s