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
I keep getting below error while trying to bind a custom model to the view. I did the route hijacking using RenderController and then in the action method, I am trying to return a custom model to the view. It gives below error. It gets resolved when I remove the Layout page reference from the view. But shows up when layout is included in the view.
ModelBindingException: Cannot bind source type WMDCExternalSitesBase.Core.Models.ComposedPageViewModel`2[[Umbraco.Cms.Web.Common.PublishedModels.Search, WMDCExternalSitesBase.Models, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null],[WMDCExternalSitesBase.Core.Models.SearchResultModel, WMDCExternalSitesBase.Core, Version=220.127.116.11, Culture=neutral, PublicKeyToken=null]] to model type Umbraco.Cms.Core.Models.PublishedContent.IPublishedContent.
Same thing is happening to me. I can remove the "inherits" from the master template and it fixes it, but then I don't get access to the model.
I tried the PublishContentWrapped mentioned here:
But it still throws the same error. It's like the master page is overriding the route-hijacked template's defined model with IPublishedContent instead of MyCustomViewModel.
Actually, the PublishedContentWrapped worked! I had to inject some stuff into the creation of the viewModel:
var viewModel = new ViewModels.SiteSearchViewModel(CurrentPage, _publishedValueFallback);
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted