Copied to clipboard

Flag this post as spam?

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

  • Goncalo 2 posts 83 karma points
    Nov 15, 2018 @ 18:01

    Bind source content type error message

    Hello guys, I'm having an issue when previewing my web page. I'm setting up a little blog section in my website and for this i have 2 Doc Types: Blog and Blog Article. Both have they're respective templates. I'm also using the Models Builder in Api mode to generate my models and therefore accessing the properties I need. When I try to preview the Blog section of my site, it gives me the following error message :

    Cannot bind source content type Agap2IT.RD.BlockBase.Website.Models.Blog to model content type Agap2IT.RD.BlockBase.Website.Models.BlogArticle

    I'm using the following instructions in the Blog template:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<BlogArticle>
    @using Agap2IT.RD.BlockBase.Website.Models

    The Blog Doc Type has BlogArticles as its children, as it's natural, and in its template I simply create a List of BlogArticles and iterate over them to access their properties (as shown below)

     @foreach (var item in articlesList)
                    <div class="card mb-4">
                        <img class="card-img-top" src="@item.PrevImage" alt="Card image cap">
                        <div class="card-body">
                            <h2 class="card-title">@item.Title</h2>
                            <p class="card-text">@item.Intro</p>
                            <a href="@item.Url" class="btn btn-primary">Read More &rarr;</a>
                        <div class="card-footer text-muted">
                            Posted on @item.PublishedDate

    Any thoughts on what i'm doing wrong? Thank you in advance :)

  • Dennis Adolfi 1072 posts 6378 karma points MVP 2x c-trib
    Nov 16, 2018 @ 07:41
    Dennis Adolfi

    Hi Goncalo.

    In your Blog Template (Blog.cshtml?), Replace this line:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<BlogArticle>

    With this line:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<Blog>

    Your trying to convert your Blog Doctype to a BlogArticle, which is not the same doctype.

    Replacing the above line should fix your binding issue.

    Best of luck to you my friend!

  • Goncalo 2 posts 83 karma points
    Nov 18, 2018 @ 18:03

    Thank you very much for your help Dennis :) great community in here!

  • Dennis Adolfi 1072 posts 6378 karma points MVP 2x c-trib
    Nov 19, 2018 @ 11:11
    Dennis Adolfi

    Glad to help Goncalo!! Have a great day!

Please Sign in or register to post replies

Write your reply to: