MVC Partial View lookup does not work OOTB

Posted by Community Admin on 04-Aug-2018 20:10

MVC Partial View lookup does not work OOTB

All Replies

Posted by Community Admin on 12-Jun-2015 00:00

Partial view lookup by the RazorViewEngine does not work with Sitefinity OOTB.

If you take the valid default paths:
"~/Views/1/0.cshtml",
"~/Views/Shared/0.cshtml"

and change them to:
"~/Mvc/Views/1/0.cshtml",
"~/Mvc/Views/Shared/0.cshtml"

then the partial view lookup works as expected.

You have to inherit the RazorViewEngine or the BuildManagerViewEngine and register it in place of the default RazorViewEngine instance in ViewEngines.Engines in Global.asax.cs Application_Start for this to work.

Posted by Community Admin on 17-Jun-2015 00:00

Hi  Richard,

Thank you for the shared solution with the community.

More information about this could be found also in that discussion.

Your contribution is appreciated.

Regards,
Svetoslav Manchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 17-Jun-2015 00:00

This should work out of the box. This solution is only a work​-around to resolve this problem, but you shouldn't have to write work-arounds into your project in order to achieve the expected, default  behavior of a key feature of the framework.

 

Regular view (i.e. not a partial) lookup does not require the additional paths to be added in order to function appropriately under the non-standard MVC foldering structure used by Sitefinity. I would expect the rest of the view file lookups to work as well.

 

Is this something that will be resolved in a future release?

Posted by Community Admin on 24-Jun-2015 00:00

Hi Richard,

Thank you for your feedback.

Actually the MVC used is Sitefinity is implemented as a part of the WebForms. Thus you have ability to use for example multiple MVC widgets on Page. In its implementation Sitefinity looking for the Views in the standard views folders Views/Controller and Shared.
In other words it is the expected behaviour not to find the Views placed in other folder/s except in case custom registration as you already mentioned in your initial post.

Note that the Views in Sitefinity could be under (~/MVC/Views) or directly in the root (~/Views).

In addition, we have test the view in a sub-folder of Shared folder on Standard MVC 4 application (attached) and the view is also not found without custom path registration discussed above.

Alternatively you can use Sitefinity Feather. Samples of custom MVC widgets with Feather could be found here and here.

I hope the information above was useful.

Your feedback and the shared solution provided are appreciated.

Regards,
Svetoslav Manchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 24-Jun-2015 00:00

The documentation for Sitefinity states:

"All MVC artifacts in Sitefinity should be stored under the Mvc folder. Everything under that folder has the same naming convention as in a new MVC project. Controllers, Views and Models are each in their respective subfolders."

 

So is the documentation wrong? Or is this an implementation oversight? The partial views work if you register the path for the folder structure suggested by the documentation, but the Editor Templates issue that I described in my other post (found here for posterity) can not be fixed by registering the additional paths. The only way to get them to work is to ignore the instructions found in the product documentation, and split your files into two areas of your project.

Posted by Community Admin on 26-Jun-2015 00:00

Hello Richard,

After further investigation and looking on the error log in the mentioned by you forum thread the issue seems related to the bug logged and discussed here.

Until the bug is being fixed you can use the workaround proposed there.

I hope the information helps.

Regards,
Svetoslav Manchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed