+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / MVC Partial View lookup does not work OOTB

MVC Partial View lookup does not work OOTB

6 posts, 0 answered
  1. RJ Cuthbertson
    RJ Cuthbertson avatar
    41 posts
    Registered:
    01 Jun 2015
    12 Jun 2015
    Link to this post

    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.
  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    17 Jun 2015
    Link to this post
    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
     
  3. RJ Cuthbertson
    RJ Cuthbertson avatar
    41 posts
    Registered:
    01 Jun 2015
    17 Jun 2015 in reply to Svetoslav Manchev
    Link to this post

    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?

  4. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    24 Jun 2015
    Link to this post
    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
     
  5. RJ Cuthbertson
    RJ Cuthbertson avatar
    41 posts
    Registered:
    01 Jun 2015
    24 Jun 2015 in reply to Svetoslav Manchev
    Link to this post

    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.

  6. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    29 Nov 2016
    26 Jun 2015
    Link to this post
    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
     
6 posts, 0 answered