Copied to clipboard

Flag this post as spam?

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


  • Hardik Gondalia 2 posts 72 karma points
    Mar 11, 2020 @ 15:24
    Hardik Gondalia
    0

    The type or namespace name 'IPublishedContent' could not be found Umbraco 8

    I've media picker in Umbraco 8 and I want to display image in my cshtml page.

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    <body>
        <section class="section">
            <div class="page-header-box">
                <img src="images/Leadership.png" />
            </div>
            <div class="ld-content-box gradientbackground">
                <div class="inner-container">
                    <h3 class="ip-title">Leadership</h3>
                    <ul class="aboutus-leadership-listing">
                        @foreach (var childPage in Model.Children())
                        {
                            <li data-aos="fade-up">
                                <div class="abll-image-box">
                                    @{
                                        var leaderImage = childPage.Value<IPublishedContent>("leaderImage");
                                    }
    

    enter image description here

    But I am getting error :

    The type or namespace name 'IPublishedContent' could not be found (are you missing a using directive or an assembly reference?)

    I don't it is issue because of Umbraco V8 or is there anything missing?

    enter image description here

  • Harikrishna Parmar 24 posts 199 karma points
    Mar 11, 2020 @ 16:29
    Harikrishna Parmar
    0

    Hello Hardik,

    Try to update the view/web.config file like this. As I have seen the config code, some namespace is not available in your config file. Try the below section in your file. Hope your problem will be fixed.

    <system.web.webPages.razor>
            <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <pages pageBaseType="System.Web.Mvc.WebViewPage">
                <namespaces>
                    <add namespace="System.Web.Mvc" />
                    <add namespace="System.Web.Mvc.Ajax" />
                    <add namespace="System.Web.Mvc.Html" />
                    <add namespace="System.Web.Routing" />
                    <add namespace="Umbraco.Web" />
                    <add namespace="Umbraco.Core" />
                    <add namespace="Umbraco.Core.Models" />
                    <add namespace="Umbraco.Core.Models.PublishedContent" />
                    <add namespace="Umbraco.Web.Mvc" />
                    <add namespace="Examine" />
                    <add namespace="Umbraco.Web.PublishedModels" />
                </namespaces>
            </pages>
        </system.web.webPages.razor>
    
  • Hardik Gondalia 2 posts 72 karma points
    Mar 13, 2020 @ 04:46
    Hardik Gondalia
    0

    Nope. that is also not working. do I need to import anything in cshtml?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies