Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IUmbracoContextFactory

    Creates and manages IUmbracoContext instances.

    Namespace: Umbraco.Cms.Core.Web
    Assembly: Umbraco.Core.dll
    Syntax
    public interface IUmbracoContextFactory

    Methods

    View Source

    EnsureUmbracoContext()

    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... }

    • Improve this Doc
    • View Source
    In This Article
    • Methods
      • EnsureUmbracoContext()
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX