Copied to clipboard

Flag this post as spam?

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


  • bh 444 posts 1544 karma points
    Jun 14, 2021 @ 18:54
    bh
    0

    The partial view 'Nested Content/ncHeroSlider' was not found or no view engine supports the searched locations.

    Umbraco v 8.14

    I got this error:

    System.InvalidOperationException: The partial view 'Nested Content/ncHeroSlider' was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/RenderMvc/Nested Content/ncHeroSlider.aspx ~/Views/RenderMvc/Nested Content/ncHeroSlider.ascx ~/Views/Shared/Nested Content/ncHeroSlider.aspx ~/Views/Shared/Nested Content/ncHeroSlider.ascx ~/Views/RenderMvc/Nested Content/ncHeroSlider.cshtml ~/Views/RenderMvc/Nested Content/ncHeroSlider.vbhtml ~/Views/Shared/Nested Content/ncHeroSlider.cshtml ~/Views/Shared/Nested Content/ncHeroSlider.vbhtml ~/Views/Partials/Nested Content/ncHeroSlider.cshtml ~/Views/MacroPartials/Nested Content/ncHeroSlider.cshtml ~/Views/Nested Content/ncHeroSlider.cshtml

    But this file does exist:

    ~/Views/Partials/Nested Content/ncHeroSlider.cshtml

    Here's my page view code:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        Layout = "BasePage.cshtml";
    }
    
    <!-- hero -->
    @if (Model.HasValue("HeroSlider")) {     
        var item = Model.Value<IEnumerable<IPublishedElement>>("HeroSlider");
        @Html.Partial($"Nested Content/ncHeroSlider", item.FirstOrDefault())
     }
    

    Here's my nested content view code:

    @using myProjectName.ModelsLibrary;
    @inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedElement>
    @{
        Layout = null;
    
        var slides = Model.Value("slides") == null ? null : Model.Value<IEnumerable<NcHeroSliderItem>>("slides");
    }
    
    <div class="hero-slider">
        @foreach(NcHeroSliderItem slide in slides) {
            var image = slide.Value("Image") == null ? null : slide.Value<MediaWithCrops>("Image").MediaItem.GetCropUrl(1600,900);
            <div style="background:url(@image) no-repeat center center;">
                @if(slide.HasValue("Content"))
                {
                    var item = Model.Value<IEnumerable<IPublishedElement>>("Content");
                    @Html.Partial($"Nested Content/ncCopyBlock", item.FirstOrDefault(), new ViewDataDictionary { { "isHeader", true } })    
                }
            </div>
        }
    </div>
    

    I've used this setup before, so I'm not sure what I'm missing.

  • Marc Goodson 2157 posts 14435 karma points MVP 10x c-trib
    Jun 14, 2021 @ 19:06
    Marc Goodson
    100

    Hi bh

    Have you tried it without the space in the folder name.

    I tend to avoid spaces in the names of folders within a solution, I wondering if it's mucking this up too?

    try renaming the folder as NestedContent and update your partials to use that , to see if it makes a difference...

    ... also noted your partial view renders a further partial view:

    Nested Content/ncCopyBlock

    is ncCopyBlock existing and in the folder locations... ?

    but hunch is, it's the 'space'.

    regards

    marc

  • bh 444 posts 1544 karma points
    Jun 14, 2021 @ 19:13
    bh
    0

    The space was the issue. I shoulda caught that. The space is fine, it was just in code, and the folder inadvertently was named NestedContent. I added a space to the actual folder name and it worked. Thx @MarcGoodson !

  • 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