new SPContext.Current
using (SPSite site = new SPSite(siteUrl)) { using (SPWeb web = site.OpenWeb(new Guid(webId))) { HttpRequest request = new HttpRequest("", web.Url, ""); HttpContext.Current = new HttpContext(request, new HttpResponse(TextWriter.Null)); if (HttpContext.Current.Items["HttpHandlerSPWeb"] == null) HttpContext.Current.Items["HttpHandlerSPWeb"] = web; return SPContext.Current; } }