Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Madison James 31 posts 147 karma points
    Sep 27, 2018 @ 06:44
    Madison James
    0

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<MyModel> causes error

    When using in a partial view

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<MyModel>
    

    I get the following error

    Cannot bind source content type ModelsBuilder.APIMode.Models.Home to model type ModelsBuilder.APIMode.Models.MyBlogPost.

    According to the Umbraco docs, https://our.umbraco.com/documentation/Reference/Templating/Mvc/partial-views Under Strongly typed Partial Views the above code should work

    Any ideas on why it doesn't? I'm using 7.10.4

    Madison

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Sep 27, 2018 @ 12:56
    Dan Diplo
    100

    Are you passing your blog post model explicitly to the partial? If you don't, then it will pass the Model of the view the page is on.

    So don't do this:

    @Html.CachePartial("MyPartial")
    

    Do this:

    @Html.CachePartial("MyPartial", blogPost)
    

    Where blogPost is you strongly typed MyBlogPost model.

  • Madison James 31 posts 147 karma points
    Sep 28, 2018 @ 03:15
    Madison James
    0

    Thank you Dan, I just got the same info from Nik on a question relative to the error being caused from this one.

Please Sign in or register to post replies

Write your reply to:

Draft