Question: I am trying to update a list item using: 

```
SPSecurity.RunWithElevatedPrivileges(delegate() 
{
    ...

    item.update();**// this line works**
    list.update();**//// exception thrown on this statement**
});

```

When I update the item, it works fine with no exception. But on updating the list... it throws an exception and redirects me to the Access Denied page.

Answer: 
Please ensure you use *SPSecurity.RunWithElevatedPrivileges* in correct way. Consider below points for the same:

* RunWithElevatedPrivileges does not work when HTTPContext is null.
* RunWithElevatedPrivileges does not work for a Sandbox Solution.
* Elevation of privilege occurs only if new SPSite created inside the block.

Below is commonly used WRONG way and you may get access denied:
 ````

SPSecurity.RunWithElevatedPrivileges(delegate()
{
      SPSite elevatedSite = SPContext.Current.Site;
      using (SPWeb elevatedWeb = elevatedSite.OpenWeb())
      {
         // Performing administrative actions here will give Access Denied exception.
      }
   }
});
````

**CORRECT Way**:

```
SPSecurity.RunWithElevatedPrivileges(delegate()
{
   using (SPSite elevatedSite = new SPSite(SPContext.Current.Site.Id))
   {
      using (SPWeb elevatedWeb = elevatedSite.OpenWeb(SPContext.Current.Web.Id))
      {
          // Perform administrative actions by using the elevated site and web objects. 
          // elevatedWeb.CurrentUser.LoginName gives SHAREPOINTsystem          
      }
   }
});

```

Please check out this post for more details: 

<http://extreme-sharepoint.com/2012/05/30/impersonation-elevation-of-privileges/>
try this code 

```
    SPSite mysite = SPContext.Current.Site;
    SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPSite mycurrentsite = new SPSite(mysite.ID);
                SPWeb mycurrentweb = mycurrentsite.OpenWeb();
                mycurrentweb.AllowUnsafeUpdates = true;
                SPList list = mycurrentweb .Lists["Some List"];      .....
                  item.update();
                  list.update();
                 mycurrentweb.AllowUnsafeUpdates = false;

            });

```