Class UmbracoContextFactory
Creates and manages UmbracoContext instances.
Inheritance
System.Object
Namespace: Umbraco.Web
Assembly: Umbraco.Web.dll
Syntax
public class UmbracoContextFactory : IUmbracoContextFactory
Constructors
View SourceUmbracoContextFactory(IUmbracoContextAccessor, IPublishedSnapshotService, IVariationContextAccessor, IDefaultCultureAccessor, IUmbracoSettingsSection, IGlobalSettings, UrlProviderCollection, MediaUrlProviderCollection, IUserService)
Initializes a new instance of the UmbracoContextFactory class.
Declaration
public UmbracoContextFactory(IUmbracoContextAccessor umbracoContextAccessor, IPublishedSnapshotService publishedSnapshotService, IVariationContextAccessor variationContextAccessor, IDefaultCultureAccessor defaultCultureAccessor, IUmbracoSettingsSection umbracoSettings, IGlobalSettings globalSettings, UrlProviderCollection urlProviders, MediaUrlProviderCollection mediaUrlProviders, IUserService userService)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoContextAccessor | umbracoContextAccessor | |
IPublishedSnapshotService | publishedSnapshotService | |
IVariationContextAccessor | variationContextAccessor | |
IDefaultCultureAccessor | defaultCultureAccessor | |
IUmbracoSettingsSection | umbracoSettings | |
IGlobalSettings | globalSettings | |
UrlProviderCollection | urlProviders | |
MediaUrlProviderCollection | mediaUrlProviders | |
IUserService | userService |
Methods
View SourceEnsureUmbracoContext(HttpContextBase)
Ensures that a current UmbracoContext exists.
Declaration
public UmbracoContextReference EnsureUmbracoContext(HttpContextBase httpContext = null)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpContextBase | httpContext | An optional http context. |
Returns
Type | Description |
---|---|
UmbracoContextReference |
Remarks
If an UmbracoContext 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.
If httpContext
is null, the factory tries to use
System.Web.HttpContext.Current if it exists. Otherwise, it uses a dummy
System.Web.HttpContextBase.