How it works...

To modify or add the View location folder, we created a class, which inherited the IViewLocationExpander interface. If we did not add the following code, we would not have to include the native Views folder location; we would replace it:

foreach(string location in viewLocations){  yield return location;}

The two native folders where the MVC mechanism would search for Views are:

"/Views/{ControllerName}" "/Views/Shared"

Now, with the following code, we will add the new Views locations:

yield return "/ViewsOld/Shared/{0}.cshtml";yield return "/ViewsOld/{1}/{0}.cshtml";

We could get the same result without using the OldViewsExpander class by just adding the following code to the ConfigureServices method:

services.Configure<RazorViewEngineOptions>(options ...

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.