Class ContentContext
Keeps track of the current context during rendering. This is used e.g. to output edit attributes for correct properties.
Inheritance
Namespace: EPiServer.Web.Mvc
Assembly: EPiServer.Cms.AspNetCore.Mvc.dll
Version: 12.0.3Syntax
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. |
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 Push
Declaration
public static void PopCurrentContent(HttpContext context, ContentReference contentLink)
Parameters
Type | Name | Description |
---|---|---|
Microsoft. |
context | The request context. |
Content |
contentLink | The content link. |
Remarks
Instead of calling Push
PopCurrentProperty(HttpContext)
Pops the current property from context. This should used in combination with Push
Declaration
public static void PopCurrentProperty(HttpContext context)
Parameters
Type | Name | Description |
---|---|---|
Microsoft. |
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. |
context | The request context. |
IContent | content | The content. |
Remarks
Instead of calling Push
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. |
context | The request context. |
System. |
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. |
context | The request context. |
System. |
propertyName | Name of the property. |
IContent |
contentLoader | The content loader. |
Returns
Type | Description |
---|---|
System. |
Remarks
This method requires that the other push, pop methods on the context is used.