ModelBindingException: Cannot bind source content type
Hi there,
I am new to web development and Umbraco. I freshly started with Umbraco v8 Cloud.
Now I have a question for better understanding of the structure or how does best practice looks like.
I get always an error message when I start my solution and I don't know how to fix that.
ModelBindingException: Cannot bind source content type Umbraco.Web.PublishedModels.HomePage to model type Umbraco.Web.PublishedModels.Product.
My solution is running in Modelbuilder AppData mode and contains a master page, a hompage and this homepage is loading several partials for a better overview:
In the partial you use "Product" model:
@inherits Umbraco.Web.Mvc.UmbracoViewPage
Model type means what document type you are browsing now, the page should be HomePage or Product, the master template should be without type at all I assume, and only document specific views should have a type.
Do I understand right, that the general policy is one page one model?
I like the strong typed feature which comes with Model Builder, but if I want multiple models on one View this is only possible with weak types and magic field strings like @Model.Value("field"), right?
ModelBindingException: Cannot bind source content type
Hi there,
I am new to web development and Umbraco. I freshly started with Umbraco v8 Cloud.
Now I have a question for better understanding of the structure or how does best practice looks like.
I get always an error message when I start my solution and I don't know how to fix that.
My solution is running in Modelbuilder AppData mode and contains a master page, a hompage and this homepage is loading several partials for a better overview:
My master source looks like this:
My homepage source:
And my partial_1 source:
Whats wrong, where is my mistake?
How is the best practice to access multiple ContentModels on one page please?
Thanks Florian
Hi Florian
In master, you use "HomePage" model :
@inherits Umbraco.Web.Mvc.UmbracoViewPage
In the partial you use "Product" model: @inherits Umbraco.Web.Mvc.UmbracoViewPage
Model type means what document type you are browsing now, the page should be HomePage or Product, the master template should be without type at all I assume, and only document specific views should have a type.
Try to remove "
Thanks,
Alex
Hi Alex,
Thanks for your advise.
Does that mean I cannot use different models in different partial views or just not in Master and details?
You can use different models.
But if you want this model types means - what type of page are you loading now.
In master usually, you can use a type that is a parent for all page types.
If partial is page specific - use page type.
If partial is using on all pages - do not use model type.
Thanks for clarification.
Do I understand right, that the general policy is one page one model?
I like the strong typed feature which comes with Model Builder, but if I want multiple models on one View this is only possible with weak types and magic field strings like @Model.Value("field"), right?
Hi Florin
You can use types and strongly typed models, but the page that is using the current template always only one type.
On home page Model that is passing to Home page template - always HomePage model.
You can retrieve any node from Umbraco tree and use strongly typed models with them on the home page, but RenderModel will be HomePage.
I hope it's possible to understand what I wrote:)
ask as many questions as possible, this community is awesome
Thanks,
Alex
Florian, let us know did you find a solution?
Alex
Yes, I got rid of the error.
It is like you said. I can only bind one model to one view.
If I want strond typed Lists I can do it like this inside a partial view:
Thanks
is working on a reply...