Class EnsurePublishedContentRequestAttribute
Used for custom routed pages that are being integrated with the Umbraco data but are not part of the umbraco request pipeline. This allows umbraco macros to be able to execute in this scenario.
Inheritance
Namespace: Umbraco.Web.Mvc
Assembly: Umbraco.Web.dll
Syntax
public class EnsurePublishedContentRequestAttribute : ActionFilterAttribute
Remarks
This is inspired from this discussion: https://our.umbraco.com/forum/developers/extending-umbraco/41367-Umbraco-6-MVC-Custom-MVC-Route?p=3
which is based on custom routing found here: http://shazwazza.com/post/Custom-MVC-routing-in-Umbraco
Constructors
View SourceEnsurePublishedContentRequestAttribute(Int32)
A constructor used to set an explicit content Id to the PublishedRequest that will be created
Declaration
public EnsurePublishedContentRequestAttribute(int contentId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | contentId |
EnsurePublishedContentRequestAttribute(String)
A constructor used to set the data token key name that contains a reference to a PublishedContent instance
Declaration
public EnsurePublishedContentRequestAttribute(string dataTokenName)
Parameters
Type | Name | Description |
---|---|---|
System.String | dataTokenName |
EnsurePublishedContentRequestAttribute(IUmbracoContextAccessor, Int32)
Constructor - can be used for testing
Declaration
public EnsurePublishedContentRequestAttribute(IUmbracoContextAccessor umbracoContextAccessor, int contentId)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoContextAccessor | umbracoContextAccessor | |
System.Int32 | contentId |
EnsurePublishedContentRequestAttribute(IUmbracoContextAccessor, String)
Constructor - can be used for testing
Declaration
public EnsurePublishedContentRequestAttribute(IUmbracoContextAccessor umbracoContextAccessor, string dataTokenName)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoContextAccessor | umbracoContextAccessor | |
System.String | dataTokenName |
Properties
View SourceUmbraco
Exposes an UmbracoHelper
Declaration
protected UmbracoHelper Umbraco { get; }
Property Value
Type | Description |
---|---|
UmbracoHelper |
UmbracoContext
Exposes the UmbracoContext
Declaration
protected UmbracoContext UmbracoContext { get; }
Property Value
Type | Description |
---|---|
UmbracoContext |
Methods
View SourceConfigurePublishedContentRequest(PublishedRequest, ActionExecutedContext)
This assigns the published content to the request, developers can override this to specify any other custom attributes required.
Declaration
protected virtual void ConfigurePublishedContentRequest(PublishedRequest request, ActionExecutedContext filterContext)
Parameters
Type | Name | Description |
---|---|---|
PublishedRequest | request | |
ActionExecutedContext | filterContext |
OnActionExecuted(ActionExecutedContext)
Declaration
public override void OnActionExecuted(ActionExecutedContext filterContext)
Parameters
Type | Name | Description |
---|---|---|
ActionExecutedContext | filterContext |