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.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>
</div>
<hr/>
}
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.
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.
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.
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.
/Views/ArticlesMain.cshtml
/Views/ArticlesItem.cshtml
/Views/MacroPartials/listArticles.cshtml
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.
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.
is working on a reply...