Copied to clipboard

Flag this post as spam?

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


  • Sebastian Dammark 581 posts 1385 karma points
    Feb 07, 2021 @ 22:24
    Sebastian Dammark
    0

    The application is in an unstable state and should be restarted.

    I'm trying to implement the Block List on a website but I get this error:

    Cannot bind source type Umbraco.Web.PublishedModels.Frontpage to model type Umbraco.Web.PublishedModels.BlockImageGrid. Both view and content models are PureLive, with same version. The application is in an unstable state and should be restarted.
    

    My template looks like this:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Frontpage>
    @using ContentModels = Umbraco.Web.PublishedModels;
    @using Umbraco.Core.Models.Blocks;
    @{
        Layout = "Master.cshtml";
    }
    <body>
        @Html.Partial("HFK/navigation")
        <div class="content-wrapper">
            @{
                var blocks = Model.ContentElements;
                foreach (var block in blocks)
                {
                    var content = block.Content;
                    @Html.Partial("BlockList/Components/" + content.ContentType.Alias)
                }
            }
        </div>
    </body>
    

    And my partial looks like this:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.BlockImageGrid>
    @using ContentModels = Umbraco.Web.PublishedModels;
    
    @{
        var images = Model.Images;
    }
    

    What the heck am I doing wrong ?

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Feb 08, 2021 @ 18:46
    Dave Woestenborghs
    1

    Hi Sebastian,

    I think the error message is confusing and hides the actual issue.

    In your partial view you need to do this :

     var images = Model.Content.Images;
    

    This because a block list item can have 2 doctypes associated. A content and a settings one.

    See https://our.umbraco.com/Documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Block-List-Editor/#1-default-rendering

    Dave

  • Sebastian Dammark 581 posts 1385 karma points
    Feb 09, 2021 @ 18:06
    Sebastian Dammark
    100

    Hi Dave

    Yeah, that looks like it could lead to trouble :)

    But I did find another solution. A good friend of mine pointed me in the direction of casting to the BlockImageGrid model, like this

    @inherits UmbracoViewPage<BlockListItem>
    @using Umbraco.Core.Models.Blocks
    @using Umbraco.Web.Models
    
    @{
        BlockImageGrid content = (BlockImageGrid)Model.Content;
        var images = content.Value<IEnumerable<IPublishedContent>>("images");
    }
    

    This solved my problems. But thanks for the input

Please Sign in or register to post replies

Write your reply to:

Draft