Cannot bind source typeContentBlockViewModel to model type IPublishedContent
Hi there,
I am trying to render a partialView within a partial that uses the
IContentBlockViewModel
Since my Breadcrumbs.cshtml partial inherits from
UmbracoViewPage
I get the following error:
Cannot bind source type Perplex.ContentBlocks.Rendering.ContentBlockViewModel`1[[Umbraco.Web.PublishedModels.HeaderBlock2, fmpool, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] to model type Umbraco.Core.Models.PublishedContent.IPublishedContent.
So your Breadcrumbs.cshtml uses IPublishedContent as model whereas you pass in the IContentBlockViewModel<>. That should indeed not work since IContentBlockViewModel does not implement IPublishedContent. Neither does Model.Content as that is IPublishedElement.
I suppose what you want is simply pass in the current PublishedContent of the request. You can change @model IContentBlockViewModel<HeaderBlock2> into @inherits UmbracoViewPage<IContentBlockViewModel<HeaderBlock2>> (so you get access to the Umbraco property), then update your partial call to:
Cannot bind source typeContentBlockViewModel to model type IPublishedContent
Hi there,
I am trying to render a partialView within a partial that uses the
Since my Breadcrumbs.cshtml partial inherits from
I get the following error:
Is there a solution?
So your
Breadcrumbs.cshtml
usesIPublishedContent
as model whereas you pass in theIContentBlockViewModel<>
. That should indeed not work sinceIContentBlockViewModel
does not implementIPublishedContent
. Neither doesModel.Content
as that isIPublishedElement
.I suppose what you want is simply pass in the current PublishedContent of the request. You can change
@model IContentBlockViewModel<HeaderBlock2>
into@inherits UmbracoViewPage<IContentBlockViewModel<HeaderBlock2>>
(so you get access to theUmbraco
property), then update your partial call to:Html.RenderPartial("~/Views/Partials/Breadcrumbs.cshtml", Umbraco.AssignedContentItem)
Daniël,
you are an absolute STAR! Thank you so much for this instant solution.
Have a great day
is working on a reply...