Partial view in MVC resource package

Posted by Community Admin on 04-Aug-2018 23:54

Partial view in MVC resource package

All Replies

Posted by Community Admin on 15-Dec-2016 00:00

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?

Posted by Community Admin on 16-Dec-2016 00:00

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.

Posted by Community Admin on 03-Jul-2017 00:00

Hi,

 

Are there any updates on this issue?

 

thanks,

Posted by Community Admin on 03-Jul-2017 00:00

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")

 

This thread is closed