Class UmbracoContext
Class that encapsulates Umbraco information of a specific HTTP request
Inheritance
System.Object
Namespace:System.Dynamic.ExpandoObject
Assembly:umbraco.dll
Syntax
public class UmbracoContext : DisposableObjectSlim, IDisposeOnRequestEnd, IDisposable
Properties
Application
Gets the current ApplicationContext
Declaration
public ApplicationContext Application { get; }
Property Value
ContentCache
Gets or sets the published content cache.
Declaration
public ContextualPublishedContentCache ContentCache { get; }
Property Value
Current
Gets the current Umbraco Context.
Declaration
public static UmbracoContext Current { get; }
Property Value
HttpContext
Exposes the HttpContext for the current request
Declaration
public HttpContextBase HttpContext { get; }
Property Value
Type |
Description |
System.Web.HttpContextBase |
|
InPreviewMode
Determines whether the current user is in a preview mode and browsing the site (ie. not in the admin UI)
Declaration
public bool InPreviewMode { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
IsDebug
Gets a value indicating whether the request has debugging enabled
Declaration
public bool IsDebug { get; }
Property Value
Type |
Description |
System.Boolean |
true if this instance is debug; otherwise, false .
|
IsFrontEndUmbracoRequest
Boolean value indicating whether the current request is a front-end umbraco request
Declaration
public bool IsFrontEndUmbracoRequest { get; }
Property Value
Type |
Description |
System.Boolean |
|
MediaCache
Gets or sets the published media cache.
Declaration
public ContextualPublishedMediaCache MediaCache { get; }
Property Value
PageId
Gets the current page ID, or null
if no page ID is available (e.g. a custom page).
Declaration
public int ? PageId { get; }
Property Value
Type |
Description |
System.Nullable<System.Int32> |
|
PublishedContentRequest
Gets/sets the PublishedContentRequest object
Declaration
public PublishedContentRequest PublishedContentRequest { get; set; }
Property Value
RoutingContext
Gets/sets the RoutingContext object
Declaration
public RoutingContext RoutingContext { get; }
Property Value
Security
Gets the WebSecurity class
Declaration
public WebSecurity Security { get; }
Property Value
UmbracoUser
Gets the current logged in Umbraco user (editor).
Declaration
[Obsolete("This should no longer be used since it returns the legacy user object, use The Security.CurrentUser instead to return the proper user object")]
public User UmbracoUser { get; }
Property Value
Type |
Description |
umbraco.BusinessLogic.User |
The Umbraco user object or null
|
UrlProvider
A shortcut to the UmbracoContext's RoutingContext's NiceUrlProvider
Declaration
public UrlProvider UrlProvider { get; }
Property Value
Methods
CreateContext(HttpContextBase, ApplicationContext, WebSecurity, IUmbracoSettingsSection, IEnumerable<IUrlProvider>, Nullable<Boolean>)
Creates a standalone UmbracoContext instance
Declaration
public static UmbracoContext CreateContext(HttpContextBase httpContext, ApplicationContext applicationContext, WebSecurity webSecurity, IUmbracoSettingsSection umbracoSettings, IEnumerable<IUrlProvider> urlProviders, bool ? preview)
Parameters
Returns
DisposeResources()
Declaration
protected override void DisposeResources()
EnsureContext(HttpContextBase, ApplicationContext)
Declaration
[Obsolete("Use the method that specifies IUmbracoSettings instead")]
public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext)
Parameters
Type |
Name |
Description |
System.Web.HttpContextBase |
httpContext |
|
ApplicationContext |
applicationContext |
|
Returns
EnsureContext(HttpContextBase, ApplicationContext, Boolean)
Declaration
[Obsolete("Use the method that specifies IUmbracoSettings instead")]
public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext)
Parameters
Type |
Name |
Description |
System.Web.HttpContextBase |
httpContext |
|
ApplicationContext |
applicationContext |
|
System.Boolean |
replaceContext |
|
Returns
EnsureContext(HttpContextBase, ApplicationContext, WebSecurity)
Declaration
[Obsolete("Use the method that specifies IUmbracoSettings instead")]
public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, WebSecurity webSecurity)
Parameters
Returns
EnsureContext(HttpContextBase, ApplicationContext, WebSecurity, Boolean)
Declaration
[Obsolete("Use the method that specifies IUmbracoSettings instead")]
public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, WebSecurity webSecurity, bool replaceContext)
Parameters
Type |
Name |
Description |
System.Web.HttpContextBase |
httpContext |
|
ApplicationContext |
applicationContext |
|
WebSecurity |
webSecurity |
|
System.Boolean |
replaceContext |
|
Returns
EnsureContext(HttpContextBase, ApplicationContext, WebSecurity, Boolean, Nullable<Boolean>)
Declaration
[Obsolete("Use the method that specifies IUmbracoSettings instead")]
public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, WebSecurity webSecurity, bool replaceContext, bool ? preview)
Parameters
Type |
Name |
Description |
System.Web.HttpContextBase |
httpContext |
|
ApplicationContext |
applicationContext |
|
WebSecurity |
webSecurity |
|
System.Boolean |
replaceContext |
|
System.Nullable<System.Boolean> |
preview |
|
Returns
EnsureContext(HttpContextBase, ApplicationContext, WebSecurity, IUmbracoSettingsSection, IEnumerable<IUrlProvider>, Boolean, Nullable<Boolean>)
This is a helper method which is called to ensure that the singleton context is created
Declaration
public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, WebSecurity webSecurity, IUmbracoSettingsSection umbracoSettings, IEnumerable<IUrlProvider> urlProviders, bool replaceContext, bool ? preview = null)
Parameters
Type |
Name |
Description |
System.Web.HttpContextBase |
httpContext |
|
ApplicationContext |
applicationContext |
|
WebSecurity |
webSecurity |
|
IUmbracoSettingsSection |
umbracoSettings |
|
System.Collections.Generic.IEnumerable<IUrlProvider> |
urlProviders |
|
System.Boolean |
replaceContext |
if set to true will replace the current singleton with a new one, this is generally only ever used because
during application startup the base url domain will not be available so after app startup we'll replace the current
context with a new one in which we can access the httpcontext.Request object.
|
System.Nullable<System.Boolean> |
preview |
|
Returns