Normally it is not required to dispose SPWeb when it is obtained from the current context.

However what happens if I create the context on my own?

        SPContext spContext = SPContext.GetContext(httpContext);
        SPWeb web = spContext.Web;

In this scenario, do I need to dispose the web?


No, you don't need to dispose objects hanging off an SPContext obtained this way.

If you look in Reflector, you'll notice SPContext.Current runs this code internally - effectively they do the same thing (which is to deserialize the context information which SharePoint stores in HttpContext.Current.Items).

Your Answer

