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

KNOWLEDGE SHEET – Stale Objects & HTTP 500 Error

Posted by Jean Paul on March 20, 2013



Stale Objects & HTTP 500 Error



Scenario – I was working for Squadron > Permissions management module. The SPWeb objects in collection were invoking Update() method multiple times.  Additionally the same SPWeb object were used in child SPList objects.  As these SPWeb objects were obsolete, invoking the Parentweb.Update() from child objects made the entire web application fault by HTTP 500 error.



Solution: Create new SPWeb objects in the child list again


public void InvokeUpdate(SPList list)








    using (SPSite site = new SPSite(list.ParentWeb.Site.Id))




      using (SPWeb web = site.OpenWeb(list.ParentWeb.Id))




        site.AllowUnsafeUpdates = true;




        site.AllowUnsafeUpdate = false;










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