Copied to clipboard

Flag this post as spam?

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


  • Jesper Ordrup 1007 posts 1505 karma points MVP
    1 week ago
    Jesper Ordrup
    0

    Umbraco content api returns incorrect blocklist data when calling from umbracoapicontroller / umbracosurfacecontroller

    When retrieving content via api we get the wrong data in blocklists. Only on some pages. Some pages consistently returns the right data and some consistently returns the wrong data.

    If we look at the page rendered in an Umbraco view - content is rendered correct.

    This works in the view:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Page>
    @using ContentModels = Umbraco.Web.PublishedModels;
    @{
        Layout = "master.cshtml";
    }
    
    @Html.GetBlockListHtml(Model, "blocks")
    

    Here are some examples that doesnt work

    Example 1 : The umbracoapicontroller

    In the controller we get data like this:

    public IHttpActionResult Get(int id, int levels = 1)
            {
    
               IPublishedContent content = UmbracoContext.Content.GetById(id);
    

    Example 2 : The umbracoapicontroller and umbracohelper

    In the controller we get data like this:

    public IHttpActionResult Get(int id, int levels = 1)
            {
    
               IPublishedContent content = Umbraco.Content(id);
    

    *Example 3: The Umbraco Surface controller *

      [HttpGet]
        public JsonResult Get(int id = 1090, int levels = 1)
        {
    
            var content = UmbracoContext.Content.GetById(id);
    

    Same difference in all 3 examples. If I debug and inspect content I can find examples where one or more of the blocks in the block list is wrong.

    I can fix the problem

    A few things tried:

    • If the editor, in Umbraco updates the block - the problem remains the same.

    • If the editor, in Umbraco sorts / moves the block - the problem remains the same.

    • If the editor copies the block and insert a new copy - the problem is fixed

    Some facts

    Problem was first spotted on a solution running on an Umbraco.sdf. We've tested migrating to sqlexpress. Problem still there.

    Discovered in Umb 8.14.1. Upgraded to latest 8.18.4. Problem still there.

  • Jesper Ordrup 1007 posts 1505 karma points MVP
    7 days ago
    Jesper Ordrup
    0

    Seen this b4? Any hints?

    😀

Please Sign in or register to post replies

Write your reply to:

Draft