Copied to clipboard

Flag this post as spam?

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


  • Rizwan 5 posts 85 karma points
    Jul 25, 2024 @ 16:14
    Rizwan
    0

    Cannot bind source content type Umbraco.Cms.Web.Common.PublishedModels.HomePage

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

    I built my blocklist and generated models since then im facing this issue this is my homePage.cshtml

    @using Umbraco.Cms.Web.Common.PublishedModels;
    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.HomeControls>
    @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
    @{
        Layout = "master.cshtml";
    }
    <body class="home">
        <div class="">
                        </div>
                    </div>
                </div>
                @Html.GetBlockListHtml(Model.SalesNewsContent)
    

    this is my SalesNewsScetion.cshtml page under Views/Partials/blocklist/Components

    @inherits UmbracoViewPage<BlockListItem>
    @using Umbraco.Cms.Core.Models.Blocks
    
    
    @{
        var row = (SalesNewsRow)Model.Content;
        var settings = (SalesNewsRowSettings)Model.Settings;
        if (settings?.Hide ?? false) { return; }
        if (row.SalesNewsItems == null || !row.SalesNewsItems.Any()) return;
    }
    
    <div class="banner-video-wrapp rows-space-40 type2">
        <div class="container">
            <div class="row">
                @foreach (var item in row.SalesNewsItems)
                {
                    var rowItem = (SalesNewsItem)item.Content;
                    var rowSettings = (SalesNewsItemSettings)item.Settings;
                    if (rowSettings.Hide) continue;
                    <div class="col-lg-6">
                        <div class="banner">
                            <div class="item-banner style9">
                                <div class="inner" style="background-image: url(@rowItem.Image!.Url();">
                                    <div class="banner-content">
                                        <h4 class="stelina-subtitle">@rowItem.Title</h4>
                                        <h3 class="title">
                                            @rowItem.Subtitle
                                        </h3>
                                        <a href="#" class="button btn-shop-now">@rowItem.ButtonTitle</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                  }
            </div>
        </div>
    </div>
    
  • Huw Reddick 1920 posts 6648 karma points MVP 2x c-trib
    Jul 26, 2024 @ 08:36
    Huw Reddick
    100

    Hi Rizwan,

    Its is complaining because of this

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.HomeControls>
    

    As this is your homepage template it is expecting it to be

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.HomPage>
    
  • Rizwan 5 posts 85 karma points
    Jul 26, 2024 @ 11:37
    Rizwan
    0

    Thanks a ton for your help Huw Reddick ! Your solution worked perfectly I'm actually new to Umbraco.

Please Sign in or register to post replies

Write your reply to:

Draft