If you run into this error, then it's likely that you're trying to do some form of Umbraco API call in application event handler, or, in some custom code outside of the normal route hi-jacking path. The error basically means the Umbraco context hasn't got far enough into the pipeline to set everything up. In today's tutorial, I'm going to cover some potential resolutions to fix this error.
var context = UmbracoContext.Current; var helper = new UmbracoHelper(context);
var helper = new UmbracoHelper(); var homepage = helper.TypedContentAtRoot();
var contentService = ApplicationContext.Current.Services.ContentService; var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
ApplicationContext.Current.Services.ContentService.GetRootContent()
using System.IO; using System.Web; using System.Web.Hosting; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Web; using Umbraco.Web.Routing; using Umbraco.Web.Security; var context = new HttpContextWrapper(new HttpContext(new SimpleWorkerRequest(/, string.Empty, new StringWriter()))); UmbracoContext.EnsureContext( context, ApplicationContext.Current, new WebSecurity(context, ApplicationContext.Current), UmbracoConfig.For.UmbracoSettings(), UrlProviderResolver.Current.Providers, false);
var context = new HttpContextWrapper(new HttpContext(new SimpleWorkerRequest(/, string.Empty, new StringWriter()))); UmbracoContext.EnsureContext( context, ApplicationContext.Current, new WebSecurity(context, ApplicationContext.Current), true);
Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge