SaaS CMS has officially launched! Learn more now.

Class ContentContext

Keeps track of the current context during rendering. This is used e.g. to output edit attributes for correct properties.

Inheritance
System.Object
ContentContext
Namespace: EPiServer.Web.Mvc
Assembly: EPiServer.Cms.AspNetCore.Mvc.dll
Version: 12.0.3
Syntax
public static class ContentContext : Object
Remarks

In case rendering is done through helper method PropertyFor then the context is created automatically.

Fields

ContentContextKey

Marker to indicate the text which is stored in httpContext.Items.

Declaration
public const string ContentContextKey = "Epi:ContentRenderingContext"
Field Value
Type Description
System.String

Methods

PopCurrentContent(HttpContext, ContentReference)

Pops the current content rendered from context. This is needed when rendering a content area since then the current rendered might differ from the routed content. So this method should be used in combination with PushCurrentContent(HttpContext, IContent).

Declaration
public static void PopCurrentContent(HttpContext context, ContentReference contentLink)
Parameters
Type Name Description
Microsoft.AspNetCore.Http.HttpContext context

The request context.

ContentReference contentLink

The content link.

Remarks

PopCurrentProperty(HttpContext)

Pops the current property from context. This should used in combination with PushCurrentProperty(HttpContext, String) and called when the property is done rendered.

Declaration
public static void PopCurrentProperty(HttpContext context)
Parameters
Type Name Description
Microsoft.AspNetCore.Http.HttpContext context

The request context.

PushCurrentContent(HttpContext, IContent)

Pushes the current content rendered to context. This is needed when rendering a content area since then the current rendered might differ from the routed content.

Declaration
public static void PushCurrentContent(HttpContext context, IContent content)
Parameters
Type Name Description
Microsoft.AspNetCore.Http.HttpContext context

The request context.

IContent content

The content.

Remarks

PushCurrentProperty(HttpContext, String)

Adds to context that the property with given name is currently rendered.

Declaration
public static void PushCurrentProperty(HttpContext context, string propertyName)
Parameters
Type Name Description
Microsoft.AspNetCore.Http.HttpContext context

The request context.

System.String propertyName

Name of the property.

ShouldRenderEditAttributes(HttpContext, String, IContentLoader)

This method can be used to determine if edit attributes should be added when rendering a property.

Declaration
public static bool ShouldRenderEditAttributes(HttpContext context, string propertyName, IContentLoader contentLoader)
Parameters
Type Name Description
Microsoft.AspNetCore.Http.HttpContext context

The request context.

System.String propertyName

Name of the property.

IContentLoader contentLoader

The content loader.

Returns
Type Description
System.Boolean
Remarks

This method requires that the other push, pop methods on the context is used.