Copied to clipboard

Flag this post as spam?

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


  • PFEW-ITSD 1 post 71 karma points
    1 week ago
    PFEW-ITSD
    0

    Receiving ModelBindingException error, but no indication of what's causing it

    I've recently begun the process of merging our Umbraco instances into a new multisite instance, using uSync to bring over the existing content. For the most part, everything is working fine but I've encountered a strange issue with 3 template files (so far) despite them using the same code as other templates connected to the same Master layout.

    ModelBindingException: Cannot bind source content type Umbraco.Cms.Web.Common.PublishedModels.MagazineIndex to model type Umbraco.Cms.Web.Common.PublishedModels.Master. Both view and content models are in memory generated, with same version. The application is in an unstable state and should be restarted.

    My first thought was to try removing the Master document type as a composition on this MagazineIndex type, but that didn't change anything. I then wondered if it was maybe an issue with the partial views in the Master template, so I removed those and still had the same error.

    I then tried copying the contents of the Master layout over to the MagazineIndex template, replacing the @RenderBody() tag with the code from the MagazineIndex template... and it worked (as long as the template was set to Layout = null;).

    What I can't understand though is why this works here when it's basically the same as if I added Layout = "Master.cshtml"; to the MagazineIndex template. Is this something to do with the ModelsBuilder setup (which is set to the defaults on this instance) or am I overlooking something?

    It's also strange because this is working perfectly on other templates, but not here. I could obviously just copy over the code from the Master template and run with that, but that wouldn't resolve the underlying issue if it comes up in the future.

    Master.cshtml

    @using Umbraco.Cms.Web.Common.PublishedModels;
    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Master>
    @using Content Models = Umbraco.Cms.Web.Common.PublishedModels;
    

    MagazineIndex.cshtml

    @using Umbraco.Cms.Web.Common.PublishedModels;
    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.MagazineIndex>
    @using Content Models = Umbraco.Cms.Web.Common.PublishedModels;
    

    Any help on this would be much appreciated, thanks!

Please Sign in or register to post replies

Write your reply to:

Draft