More in this section
Forums / Developing with Sitefinity / Partial view in MVC resource package

Partial view in MVC resource package

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 0 answered
  1. Ross
    Ross avatar
    0 posts
    Registered:
    03 Mar 2016
    15 Dec 2016
    Link to this post

    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?

  2. Ross
    Ross avatar
    0 posts
    Registered:
    03 Mar 2016
    16 Dec 2016
    Link to this post

    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.

  3. trevor
    trevor avatar
    0 posts
    Registered:
    03 Dec 2013
    03 Jul 2017
    Link to this post

    Hi,

     

    Are there any updates on this issue?

     

    thanks,

  4. Ross
    Ross avatar
    0 posts
    Registered:
    03 Mar 2016
    03 Jul 2017
    Link to this post

    I was originally facing issues because I had the file extension in the Partial reference. I was able to get it working without. See http://knowledgebase.progress.com/articles/Article/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")

     

4 posts, 0 answered