{"id":747,"date":"2011-12-19T22:28:46","date_gmt":"2011-12-19T22:28:46","guid":{"rendered":"http:\/\/www.stuartroberts.net\/?p=747"},"modified":"2012-04-18T10:11:01","modified_gmt":"2012-04-18T09:11:01","slug":"remove-property-sppropertybag","status":"publish","type":"post","link":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/","title":{"rendered":"Remove property from SPPropertyBag"},"content":{"rendered":"<p>Have you ever tried to remove a property from a SPWeb object and after applying the update, when you next check for the property it is still there?<\/p>\n<p>Logically, you&#8217;d think the following code would do this for you:<\/p>\n<pre lang=\"csharp\">\r\nwebObject.Properties.Remove(\"yourkey\");\r\nwebObject.Properties.Update();\r\n<\/pre>\n<p>But, I&#8217;ve found, if you reload the SPWeb object and check for the key, it still exists, even though it had been previously removed.  To successfully remove a property from the web&#8217;s property bag, try setting the property to null, as shown below.<\/p>\n<pre lang=\"csharp\">\r\nwebObject.Properties[\"yourkey\"] = null;\r\nwebObject.Properties.Update();\r\n<\/pre>\n<p>Now when you reload the SPWeb object and check for the property, it won&#8217;t exist.  It seems that the <em>Remove<\/em> method is either flaky, or the change is not being persisted after applying the update on the <em>Properties<\/em> property.<\/p>\n<p>Of course, you really should be using the new <em>AllProperties<\/em> property instead, where this issue is not present.  This property was added to 2010 and uses a HashTable instead of the SPPropertyBag.  Items added to <em>AllProperties<\/em> will filter down to <em>Properties<\/em> but not the reverse.  Most (if not all) of the internal properties use the old <em>Properties<\/em> property, so there are still certain cases where you&#8217;d want to manipulate them.  How you work with them is slightly different, for example:<\/p>\n<pre lang=\"csharp\">\r\n\/\/ Remove from old style Properties\r\nwebObject.Properties[\"yourkey\"] = null;\r\nwebObject.Properties.Update();\r\n\r\n\/\/ Remove from new AllProperties\r\nwebObject.AllProperties.Remove(\"yourkey\");\r\nwebObject.Update();\r\n<\/pre>\n<p>Nothing too different, instead of updating the property collection directly you you just update the parent web or site object.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever tried to remove a property from a SPWeb object and after applying the update, when you next check for the property it is still there? Logically, you&#8217;d think the following code would do this for you: webObject.Properties.Remove(&#8220;yourkey&#8221;); &hellip; <a href=\"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[3],"tags":[40,81],"class_list":["post-747","post","type-post","status-publish","format-standard","hentry","category-sharepoint","tag-propertybag","tag-sharepoint"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"How to successfully remove a property from the SPPropertyBag for a SPWeb object\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Stu\"\/>\n\t<meta name=\"keywords\" content=\"sharepoint,sps,sp,sppropertybag\" \/>\n\t<link rel=\"canonical\" href=\"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_GB\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Stuart Roberts on all things SharePoint |\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint\" \/>\n\t\t<meta property=\"og:description\" content=\"How to successfully remove a property from the SPPropertyBag for a SPWeb object\" \/>\n\t\t<meta property=\"og:url\" content=\"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2011-12-19T22:28:46+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2012-04-18T09:11:01+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@SharePointStu\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint\" \/>\n\t\t<meta name=\"twitter:description\" content=\"How to successfully remove a property from the SPPropertyBag for a SPWeb object\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@SharePointStu\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#article\",\"name\":\"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint\",\"headline\":\"Remove property from SPPropertyBag\",\"author\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#articleImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/503cb376bab10c66a6bde71d1514dcab2eab4ec44a2f82ef597ca87af61bf1cd?s=96&d=retro&r=g\",\"width\":96,\"height\":96,\"caption\":\"Stu\"},\"datePublished\":\"2011-12-19T22:28:46+00:00\",\"dateModified\":\"2012-04-18T10:11:01+01:00\",\"inLanguage\":\"en-GB\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#webpage\"},\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#webpage\"},\"articleSection\":\"SharePoint, PropertyBag, SharePoint\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.stuartroberts.net\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/category\\\/sharepoint\\\/#listItem\",\"name\":\"SharePoint\"}},{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/category\\\/sharepoint\\\/#listItem\",\"position\":2,\"name\":\"SharePoint\",\"item\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/category\\\/sharepoint\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#listItem\",\"name\":\"Remove property from SPPropertyBag\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#listItem\",\"position\":3,\"name\":\"Remove property from SPPropertyBag\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/category\\\/sharepoint\\\/#listItem\",\"name\":\"SharePoint\"}}]},{\"@type\":\"Person\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/#person\",\"name\":\"Stu\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/503cb376bab10c66a6bde71d1514dcab2eab4ec44a2f82ef597ca87af61bf1cd?s=96&d=retro&r=g\",\"width\":96,\"height\":96,\"caption\":\"Stu\"}},{\"@type\":\"Person\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/author\\\/admin\\\/#author\",\"url\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/author\\\/admin\\\/\",\"name\":\"Stu\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/503cb376bab10c66a6bde71d1514dcab2eab4ec44a2f82ef597ca87af61bf1cd?s=96&d=retro&r=g\",\"width\":96,\"height\":96,\"caption\":\"Stu\"}},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#webpage\",\"url\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/\",\"name\":\"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint\",\"description\":\"How to successfully remove a property from the SPPropertyBag for a SPWeb object\",\"inLanguage\":\"en-GB\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/#website\"},\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/2011\\\/12\\\/19\\\/remove-property-sppropertybag\\\/#breadcrumblist\"},\"author\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/index.php\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2011-12-19T22:28:46+00:00\",\"dateModified\":\"2012-04-18T10:11:01+01:00\"},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/#website\",\"url\":\"http:\\\/\\\/www.stuartroberts.net\\\/\",\"name\":\"Stuart Roberts on all things SharePoint\",\"inLanguage\":\"en-GB\",\"publisher\":{\"@id\":\"http:\\\/\\\/www.stuartroberts.net\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint","description":"How to successfully remove a property from the SPPropertyBag for a SPWeb object","canonical_url":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/","robots":"max-image-preview:large","keywords":"sharepoint,sps,sp,sppropertybag","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#article","name":"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint","headline":"Remove property from SPPropertyBag","author":{"@id":"http:\/\/www.stuartroberts.net\/index.php\/author\/admin\/#author"},"publisher":{"@id":"http:\/\/www.stuartroberts.net\/#person"},"image":{"@type":"ImageObject","@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#articleImage","url":"https:\/\/secure.gravatar.com\/avatar\/503cb376bab10c66a6bde71d1514dcab2eab4ec44a2f82ef597ca87af61bf1cd?s=96&d=retro&r=g","width":96,"height":96,"caption":"Stu"},"datePublished":"2011-12-19T22:28:46+00:00","dateModified":"2012-04-18T10:11:01+01:00","inLanguage":"en-GB","mainEntityOfPage":{"@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#webpage"},"isPartOf":{"@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#webpage"},"articleSection":"SharePoint, PropertyBag, SharePoint"},{"@type":"BreadcrumbList","@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"http:\/\/www.stuartroberts.net\/#listItem","position":1,"name":"Home","item":"http:\/\/www.stuartroberts.net\/","nextItem":{"@type":"ListItem","@id":"http:\/\/www.stuartroberts.net\/index.php\/category\/sharepoint\/#listItem","name":"SharePoint"}},{"@type":"ListItem","@id":"http:\/\/www.stuartroberts.net\/index.php\/category\/sharepoint\/#listItem","position":2,"name":"SharePoint","item":"http:\/\/www.stuartroberts.net\/index.php\/category\/sharepoint\/","nextItem":{"@type":"ListItem","@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#listItem","name":"Remove property from SPPropertyBag"},"previousItem":{"@type":"ListItem","@id":"http:\/\/www.stuartroberts.net\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#listItem","position":3,"name":"Remove property from SPPropertyBag","previousItem":{"@type":"ListItem","@id":"http:\/\/www.stuartroberts.net\/index.php\/category\/sharepoint\/#listItem","name":"SharePoint"}}]},{"@type":"Person","@id":"http:\/\/www.stuartroberts.net\/#person","name":"Stu","image":{"@type":"ImageObject","@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/503cb376bab10c66a6bde71d1514dcab2eab4ec44a2f82ef597ca87af61bf1cd?s=96&d=retro&r=g","width":96,"height":96,"caption":"Stu"}},{"@type":"Person","@id":"http:\/\/www.stuartroberts.net\/index.php\/author\/admin\/#author","url":"http:\/\/www.stuartroberts.net\/index.php\/author\/admin\/","name":"Stu","image":{"@type":"ImageObject","@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/503cb376bab10c66a6bde71d1514dcab2eab4ec44a2f82ef597ca87af61bf1cd?s=96&d=retro&r=g","width":96,"height":96,"caption":"Stu"}},{"@type":"WebPage","@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#webpage","url":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/","name":"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint","description":"How to successfully remove a property from the SPPropertyBag for a SPWeb object","inLanguage":"en-GB","isPartOf":{"@id":"http:\/\/www.stuartroberts.net\/#website"},"breadcrumb":{"@id":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/#breadcrumblist"},"author":{"@id":"http:\/\/www.stuartroberts.net\/index.php\/author\/admin\/#author"},"creator":{"@id":"http:\/\/www.stuartroberts.net\/index.php\/author\/admin\/#author"},"datePublished":"2011-12-19T22:28:46+00:00","dateModified":"2012-04-18T10:11:01+01:00"},{"@type":"WebSite","@id":"http:\/\/www.stuartroberts.net\/#website","url":"http:\/\/www.stuartroberts.net\/","name":"Stuart Roberts on all things SharePoint","inLanguage":"en-GB","publisher":{"@id":"http:\/\/www.stuartroberts.net\/#person"}}]},"og:locale":"en_GB","og:site_name":"Stuart Roberts on all things SharePoint |","og:type":"article","og:title":"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint","og:description":"How to successfully remove a property from the SPPropertyBag for a SPWeb object","og:url":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/","article:published_time":"2011-12-19T22:28:46+00:00","article:modified_time":"2012-04-18T09:11:01+00:00","twitter:card":"summary","twitter:site":"@SharePointStu","twitter:title":"Remove property from SPPropertyBag | Stuart Roberts on all things SharePoint","twitter:description":"How to successfully remove a property from the SPPropertyBag for a SPWeb object","twitter:creator":"@SharePointStu"},"aioseo_meta_data":{"post_id":"747","title":"Remove property from SPPropertyBag | #site_title","description":"How to successfully remove a property from the SPPropertyBag for a SPWeb object","keywords":[{"label":"SharePoint","value":"SharePoint"},{"label":"SPS","value":"SPS"},{"label":"SP","value":"SP"},{"label":"SPPropertyBag","value":"SPPropertyBag"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-08-03 13:50:56","updated":"2026-10-15 18:50:06","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"http:\/\/www.stuartroberts.net\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"http:\/\/www.stuartroberts.net\/index.php\/category\/sharepoint\/\" title=\"SharePoint\">SharePoint<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tRemove property from SPPropertyBag\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"http:\/\/www.stuartroberts.net\/"},{"label":"SharePoint","link":"http:\/\/www.stuartroberts.net\/index.php\/category\/sharepoint\/"},{"label":"Remove property from SPPropertyBag","link":"http:\/\/www.stuartroberts.net\/index.php\/2011\/12\/19\/remove-property-sppropertybag\/"}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/comments?post=747"}],"version-history":[{"count":7,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/747\/revisions"}],"predecessor-version":[{"id":979,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/posts\/747\/revisions\/979"}],"wp:attachment":[{"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/media?parent=747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/categories?post=747"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.stuartroberts.net\/index.php\/wp-json\/wp\/v2\/tags?post=747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}