Interface IUmbracoContextFactory
Creates and manages IUmbracoContext instances.
Namespace: Umbraco.Cms.Core.Web
Assembly: Umbraco.Core.dll
Syntax
public interface IUmbracoContextFactoryMethods
View SourceEnsureUmbracoContext()
Ensures that a current IUmbracoContext exists.
Declaration
UmbracoContextReference EnsureUmbracoContext()Returns
| Type | Description | 
|---|---|
| UmbracoContextReference | 
Remarks
If an IUmbracoContext is already registered in the IUmbracoContextAccessor, returns a non-root reference to it. Otherwise, create a new instance, registers it, and return a root reference to it.
Examples
using (var contextReference = contextFactory.EnsureUmbracoContext()) { var umbracoContext = contextReference.UmbracoContext; // use umbracoContext... }