Copied to clipboard

Flag this post as spam?

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


  • Frank Medium 12 posts 121 karma points
    May 25, 2021 @ 12:03
    Frank Medium
    0

    Issue with partial view inheriting model

    Hi, I am new to Umbraco so I hope the below make sense.

    I am getting this error when loading my page

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

    The page template itself calls a partial view like this

    @foreach (IPublishedContent sectionItem in Model.Content.Content)
                {
    
                    @Html.Partial("NestedInternalComms/_" + sectionItem.DocumentTypeAlias, sectionItem);
    
                 }
    

    The partial view then has the following import statements at the top

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<InternalCommsVideo>
    @using Umbraco.Web.PublishedContentModels;
    

    This appears to be the same pattern the rest of my pages are set up with.

    I am able to see the InternalCommsVideo within App_Data/Models so I am not sure why I am getting this error.

    Can anyone please help? If you need further information please let me know.

    Thanks

  • AddWeb Solution Pvt. Ltd 109 posts 360 karma points
    May 26, 2021 @ 13:42
    AddWeb Solution Pvt. Ltd
    0

    Hello Sam,

    Try to follow these steps :-

    -Clean solution

    -Delete all "bin" and "obj" Folders (from the whole solution) manually

    -Restart VS

    -Rebuild all

  • Frank Medium 12 posts 121 karma points
    May 26, 2021 @ 16:34
    Frank Medium
    0

    Hi, just tried this suggestion but unfortunately still the same error

  • Huw Reddick 1758 posts 6124 karma points MVP c-trib
    May 26, 2021 @ 16:53
    Huw Reddick
    0

    try referencing InternalCommsVideo using it's namespace

    like below 9using whatever your models namespace is

    Vantage.Models.InternalCommsVideo

  • Frank Medium 12 posts 121 karma points
    May 26, 2021 @ 16:58
    Frank Medium
    0

    Hi Huw,

    Just tried this aswell, but unfortunately still getting the same error

  • Søren Kottal 702 posts 4497 karma points MVP 5x c-trib
    May 26, 2021 @ 19:15
    Søren Kottal
    0

    What are your models builder settings?

  • Frank Medium 12 posts 121 karma points
    May 27, 2021 @ 07:51
    Frank Medium
    0

    The below is current set in web.config

     <add key="Umbraco.ModelsBuilder.Enable" value="true" />
     <add key="Umbraco.ModelsBuilder.ModelsMode" value="AppData" />
    
  • Frank Medium 12 posts 121 karma points
    May 27, 2021 @ 09:35
    Frank Medium
    100

    Ok think I have now resolved this issue.

    When creating the document type and partial view through backoffice the .cshtml and generated .cs files were not being added to the project and .csproj.

    After going into Visual Studio and adding them to the project everything seems to work ok.

    Not sure if this is normal behaviour or not.

  • Søren Kottal 702 posts 4497 karma points MVP 5x c-trib
    May 27, 2021 @ 10:34
    Søren Kottal
    1

    It is :)

Please Sign in or register to post replies

Write your reply to:

Draft