hi everyone,
can anyone help me to resolve this error
Cannot return the IPublishedContent because the UmbracoHelper was constructed with an UmbracoContext and the current request is not a front-end request.
If you are seeing that error in a Partial View, where you are trying to construct the Umbraco helper with the current assigned content item, instead try this:
Let your custom model inherit from Umbraco.Web.Models.RenderModel, and use the following ctor:
public MyCustomModel() : base(UmbracoContext.Current.PublishedContentRequest.PublishedContent)
{ }
That will allow you to access Model.Content in your partial, in addition to your custom model properties.
Umbraco Routing
hi everyone, can anyone help me to resolve this error Cannot return the IPublishedContent because the UmbracoHelper was constructed with an UmbracoContext and the current request is not a front-end request.
If you are seeing that error in a Partial View, where you are trying to construct the Umbraco helper with the current assigned content item, instead try this:
Let your custom model inherit from
Umbraco.Web.Models.RenderModel
, and use the following ctor:That will allow you to access Model.Content in your partial, in addition to your custom model properties.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.