Copied to clipboard

Flag this post as spam?

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


  • Yaco Zaragoza 88 posts 362 karma points
    Apr 05, 2023 @ 19:24
    Yaco Zaragoza
    0

    ModelBindingException: Cannot bind source type

    I am trying to build a blog page but I am getting the following error.

    An unhandled exception occurred while processing the request.

    ModelBindingException: Cannot bind source type Umbraco.Cms.Web.Common.PublishedModels.NewsAndAnnouncementsItemsPage to model type Umbraco.Cms.Web.Common.PublishedModels.IMetaProperties. Umbraco.Cms.Web.Common.ModelBinders.ContentModelBinder.ThrowModelBindingException(bool sourceContent, bool modelContent, Type sourceType, Type modelType)

    Can someone tell me why?

    Here is some information about what I did.

    I created a Composition called "News and Announcements Properties" that has a property (textString) called News Title

    Then I created 2 page types

    the first one called "News and Announcements Page" that inherits the "News and Announcements Properties composition"

    the second one called "News and Announcements Items Page" that inherits the "News and Announcements Properties composition" and it also has additional properties "News Content" (Textarea) and "News Attachment" (Media Picker)

    Then I created a page under content called "News" and then I created 3 children items under it (See attachment for clarification)

    enter image description here

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Apr 05, 2023 @ 20:41
    Marc Goodson
    0

    Hi Yaco

    Does your site have another composition called .MetaProperties?

    The error message is suggesting that your new document type

    NewsAndAnnouncementsItemsPage

    Doesn't have the properties of this composition and I suspect there is code somewhere in your site that writes out these meta properties on all pages and is throwing the error because your new doc type doesn't have them...?

    Regards

    Marc

  • Yaco Zaragoza 88 posts 362 karma points
    Apr 06, 2023 @ 13:15
    Yaco Zaragoza
    0

    Hello Mark,

    Yes I have a composition called Meta Properties (metaProperties) and both pages "News and Announcements Page" and "News and Announcements Items Page" inherit meta properties...

    enter image description here

    enter image description here

    Also, both pages use the master template which calls the meta partial.

    Here is the code from the Master page

    @using Umbraco.Cms.Web.Common.PublishedModels;
    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
    @{
        Layout = null;
    }
    <!DOCTYPE html>
    <html lang="en">
    <head>
    
        @await Html.PartialAsync("~/Views/Partials/_meta_data.cshtml")
    

    and this is the code on the meta data partial

    @inherits UmbracoViewPage<IMetaProperties>
    
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="x-ua-compatible" content="ie=edge" />
    
    
    <title>@Model.MetaTitle</title>
    <meta name="author" content="Yaco Zaragoza" />
    <meta name="description" content="@Model.MetaDescription">
    <meta name="keywords" content="@Model.MetaKeywords">
    

    How do I solve this issue?

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft