Copied to clipboard

Flag this post as spam?

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


  • Christina 127 posts 390 karma points notactivated
    May 28, 2018 @ 07:02
    Christina
    0

    Display properties in a partialview

    Hi I need som help with displaying properies in a partialview on masterpage thanks Christina

     @Html.CachedPartial("Page/_PageMetaData", Model.Content, 300, true, false)
    

    And in my partail view

    @inherits UmbracoViewPage<MetaData>     
    <meta name="title" content="@Model.PTitle"     />
        <meta name="description" content="@Model.SeoMetaDescription" />
        <meta name="keywords" content="@Model.Keywords" />
    

    I get this error

    Cannot bind source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to model content type Umbraco.Web.PublishedContentModels.Home.
    
  • Andy Felton 185 posts 484 karma points c-trib
    May 28, 2018 @ 09:12
    Andy Felton
    0

    Hi Christina,

    Can you let us know what your master page is inheriting from please?

    It may be worth removing the call to the @Html.CachedPartial for rendering the Meta data as I little surprised that line is trying to bind your object to Umbraco.Web.PublishedContentModels.Home.

    One other change would be instead of passing the Model.Content instead just pass Model.

    Andy

  • Christina 127 posts 390 karma points notactivated
    May 28, 2018 @ 09:28
    Christina
    0

    Hi Andy Thanks

    I Have removed partial and only passing Model but i still get error

    This is masterpage

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage 
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @using Umbraco.Core
    

    /Christina

  • Andy Felton 185 posts 484 karma points c-trib
    May 28, 2018 @ 09:36
    Andy Felton
    0

    Hi Christina,

    If you've removed the call to

    @Html.CachedPartial("Page/_PageMetaData", Model.Content, 300, true, false)
    

    and you're still getting the error then I suspect the error maybe somewhere else in Master page. From the error message what I suspect is happening is that somewhere the master page you're trying to render a partial which is inheriting from Home. From MasterPage this wouldn't be possible as the page template could be anything.

    Andy

  • Christina 127 posts 390 karma points notactivated
    May 28, 2018 @ 09:46
    Christina
    0

    Hi Andy thanks for helping me I think its this in @inherits Umbraco.Web.Mvc.UmbracoTemplatePage masterpage that generating the errror but in masterpage ihave a lot of doctypes. I get the error from masterpage the errormessage Home because I'm on homepage if i go to a Contentpage

    I get this error

    Cannot bind source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to model content type Umbraco.Web.PublishedContentModels.ContentPage.
    

    I have include the doctype on page and generated the model and attatched webconfig. The strange the intellicense in VS works and its no error. If i use this code it work

    @inherits UmbracoViewPage
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    <meta name="title" content="@Model.GetPropertyValue("pTitle")" />
    
  • Andy Felton 185 posts 484 karma points c-trib
    May 28, 2018 @ 11:02
    Andy Felton
    0

    Hi Christina,

    I think you're correct, I've tried something similar in one of my projects and get a similar error.

    The issue is (I think) in the Master Page you've got to inherit from UmbracoTemplatePage (or one of the similar classes), the code then can't at runtime bind to the MetaData class because you're using one of the base classes.

    Somebody more experienced from the community may be able to provide a better explanation.

    Andy

Please Sign in or register to post replies

Write your reply to:

Draft