Partial view in MVC resource package - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Partial view in MVC resource package

  • Partial view in MVC resource package
  • I have a resource package with the following structure:

    ResourcePackages > MyPackage > MVC > Views > Layouts > MainLayout.cshtml

    In MainLayout I am wanting to include partial files that are in the same directory:

    @Html.Partial("Menu")

    Frustratingly, Sitefinity doesn't look in the immediate folder for a partial. Instead it generates the following error:

    [InvalidOperationException: The partial view 'Menu' was not found or no view engine supports the searched locations. The following locations were searched:
    ~/Views/Generic/Menu.cshtml
    ~/Views/Shared/Menu.cshtml
    ~/Views/Generic/Menu.aspx
    ~/Views/Generic/Menu.ascx
    ~/Views/Shared/Menu.aspx
    ~/Views/Shared/Menu.ascx
    ~/Views/Generic/Menu.vbhtml
    ~/Views/Shared/Menu.vbhtml]

     

    How can I refer to a partial view from within a resource package?

  • I have tried placing the partial in the following locations with no luck:
    ResourcePackages > MyPackage > Shared
    ResourcePackages > MyPackage > MVC > Shared
    ResourcePackages > MyPackage > MVC > Views > Shared
    ResourcePackages > MyPackage > MVC > Views > Layouts

     

    Any advice would be appreciated.

  • Hi,

     

    Are there any updates on this issue?

     

    thanks,

  • I was originally facing issues because I had the file extension in the Partial reference. I was able to get it working without. See knowledgebase.progress.com/.../refer-to-partial-view-in-mvc-resource-package-views

    I have some fragment files in my current project that are working as expected:

    /ResourcePackages/MyPackage/Mvc/Views/Layouts/Skeleton.cshtml
    /ResourcePackages/MyPackage/Mvc/Views/Layouts/Fragments/_Header.cshtml

    In Skeleton I reference the partial like so:

    @Html.Partial("Fragments/_Header")