Yes, there are hidden pockets in SharePoint's property bags. Even if you call web.Properties.Update() you may not persist the changes. Call web.Update() after. For instance, this is how one can delete from the property bag:
if (currentWeb.Properties.ContainsKey(newKey))
{
currentWeb.AllowUnsafeUpdates = true;
currentWeb.Properties.Remove(newKey);
currentWeb.Properties.Update();
currentWeb.AllProperties.Remove(newKey);
currentWeb.AllowUnsafeUpdates = false;
currentWeb.AllowUnsafeUpdates = true;
currentWeb.Update();
currentWeb.AllowUnsafeUpdates = false;
}
Yes, one must wrap changes with the AllowUnsafeUpdates set.
(I spent hours trying to understand this hidden feature)
No comments:
Post a Comment