Copied to clipboard

Flag this post as spam?

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

  • Sprite 15 posts 135 karma points
    Jul 09, 2018 @ 08:46

    Cannot bind source content type ArticleItem to model content type ArticlesMain

    This is the first time we have tried Umbraco and we are following a official tutorial to create a Arcticle/News functionality as an example.

    We basically started from the top here

    So, first we created a Homepage and so a Masterpage, and everything in between until we reach this point.

    And everything displayed works, we have a overview, the Macro/Partial View is working great.

    But when we want to navigate to the actual ArticleItem, we run into the error mentioned in the title.

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

    Now, my guess is that it is an issue with the Masterpage being the ArticlesMain template, and this enforces that Model to be used/passed down to the ArticlesItem pages. But my MVC is quite rusty, so it seems I can't figure out a solution myself at this time.

    The code used is copied 1:1 from the tutorial to make sure we didn't mess anything up, but no dice so far. We also did everything in the Umbraco CMS, our IDE (VS) was not used.


    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
      @using ContentModels = Umbraco.Web.PublishedContentModels; @{ Layout = "HomePage.cshtml"; }
      <div id="main-container">
        <div id="main" class="wrapper clearfix">
        <!-- #main -->
      <!-- #main-container -->


    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
      @using ContentModels = Umbraco.Web.PublishedContentModels; @{ Layout = "ArticlesMain.cshtml"; }


    @inherits Umbraco.Web.Macros.PartialViewMacroPage
        var selection = CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"); 
        @* OrderBy() takes the property to sort by and optionally order desc/asc *@
    @foreach (var item in selection)
        <div class="article">
            <div class="articletitle"><a href="@item.Url">@item.Name</a></div>
            <div class="articlepreview">@Umbraco.Truncate(@item.ArticleContents,100) <a href="@item.Url">Read More..</a></div>

    As for the Document Types, they looks exactly as in the tutorial's screenshots, I could provide those as well of course, including the set permissions.

  • David Brendel 786 posts 2952 karma points MVP c-trib
    Jul 10, 2018 @ 10:02
    David Brendel

    Hi Sprite,

    this is caused as the model that is used in the view is not of the correct type. You used Layout = "ArticleMain.cshtml" in your view for the ArticleDetails which causes the ArticleMain.cshtml to be used as a parent view. This view needs a model of type ArticleMain. Switching to "Layout=Master.cshtml" should solve the issue. At least this seems to be the master view in the tutorial.

Please Sign in or register to post replies

Write your reply to: