Try our conversational search powered by Generative AI!

Razor views in the protected module doesn't work by virtual path.

Vote:
 

I am creating a protected module. Here is the structure of the files under _protected:

Web.config is the common one as in usual MVC application for views to be able to work properly.

Then I have a controller in which I am explicitly setting view path using a virtual path to the "modules/_protected" which is "~/cms/":

public class CustomerController : Controller
{
    public ActionResult Index()
    {
        // Doesn't work
        return View("~/cms/Customer/Views/Customer/Index.cshtml");

        // Works
        //return View("~/modules/_protected/Customer/Views/Customer/Index.cshtml");
    }
}

With this configuration I get such error:

When I change the path to the file structure (~/modules/_protected/Customer/Views/Customer/Index.cshtml) then a view is resolved correctly.

Is there any configuration needed to make Razor views work with virtual paths?

Also, is there any configuration available to enable Razor views in the module ViewEngine? Now it seems that only WebForm views are resolved.

#175810
Mar 02, 2017 16:46
Vote:
 

I've reported this before as a bug, but the developer team have decided this is a feature request. CMS-1506 or CMS-3891, note that they're not in the public bug list.

#175840
Mar 03, 2017 19:49
Vote:
 

I wrote an article on how to setup Razor views for Episerver modules: http://marisks.net/2017/03/05/configuring-razor-view-support-for-episerver-modules/

#175870
Mar 05, 2017 11:10
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.