Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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:
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">
<a href="@item.Url" class="btn btn-primary">Read More →</a>
<div class="card-footer text-muted">
Posted on @item.PublishedDate
Any thoughts on what i'm doing wrong? Thank you in advance :)
In your Blog Template (Blog.cshtml?), Replace this line:
With this line:
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!
Thank you very much for your help Dennis :) great community in here!
Glad to help Goncalo!!
Have a great day!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted