jump to navigation

SPContext.Current == null August 30, 2016

Posted by juanpablo1manrique in SharePoint.

Create fake SPContext.Current

using (SPSite oSPsite = new SPSite(webUrl))
using (SPWeb oSPWeb = oSPsite.OpenWeb())

HttpContext newContext = null;
if (HttpContext.Current == null)
var request = new HttpRequest(“”, oSPWeb.Url, “”);
newContext = new HttpContext(request, new HttpResponse(TextWriter.Null));
HttpContext.Current = newContext;
HttpContext.Current.Items[“HttpHandlerSPWeb”] = oSPWeb;
HttpContext.Current.Items[“HttpHandlerSPSite”] = oSPsite;


No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: