Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mahmoud 1 post 71 karma points
    Apr 01, 2016 @ 12:53
    mahmoud
    0

    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.

  • Barry Fogarty 493 posts 1129 karma points
    Apr 04, 2016 @ 18:49
    Barry Fogarty
    0

    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.

  • 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.

Please Sign in or register to post replies