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

Viewed 1242

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?

UPDATED: enter image description here

3 Answers

IPublishedContent is defined in the Umbraco.Core.Models namespace.

You should have an entry

<add namespace="Umbraco.Core.Models" />

in the system.web.webPages.razor/pages/namespaces section of Views\Web.config.

IPublishedContent moved again, now it resides in Umbraco.Core.Models.PublishedContent:

using Umbraco.Core.Models.PublishedContent;

For namespace and Library

@using Umbraco.Core.Models

For Model

@model Umbraco.Core.Models

For Iterate the list on Razor Page (You Have to use foreach loop for access the list items)

Related