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

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.

Mar 02, 2017 16:46
First   1   Last