Conventions for EPiServer 7 MVC Views

This article was migrated from an older iteration of our website, and it could deviate in design and functionality.


ASP.NET MVC is largely built on conventions for controllers, models, and views. However, I prefer tweaking these conventions a bit for EPiServer 7 sites to separate block views from page views.

Estimated read time : 1 minutes

Jump to

Building a web site on EPiServer 7 using ASP.NET MVC, you will probably end up with a fairly long list of blocks and pages as the site grows. EPiServer 7 follows the MVC convention of searching ~/Views/ for all views, which means blocks and pages will both be located in that folder.

I want to separate block views from page views, using the folders ~/Views/Blocks/ and ~/Views/Pages/. To customize the MVC search convention to handle these additional paths, you need to add a class deriving from RazorViewEngine, like so:

Customizing ASP.NET MVC conventions to use a different folder structure

Then you need to register the engine, which you can do in the Application_Start method in your Global.asax file:

image

That’s it!