Configuring view and area locations
In this recipe, you will learn how to change the view location used per convention by ASP.NET Core MVC.
Getting ready
We will use the previous recipe and add some modifications to use a different view location.
How to do it...
- First, let's create a new views folder named
ViewsOld. In this folder, we will copy_ViewImports.cshtmland_ViewSart/cshtmlfrom theViewsfolder, and cut theProductviews folder to paste it into theViewsOldfolder:

- Next, we create a folder named
Infrastructureand create a C# class namedOldViewsExpander.cs. This class will contain the following code:
public class OldViewsExpander : IViewLocationExpander
{
public IEnumerable<string> ExpandViewLocations
(ViewLocationExpanderContext context,
IEnumerable<string> viewLocations)
{
// rerturn all classic locations
foreach (string location in viewLocations)
{
yield return location;
}
// return new locations
yield return "/ViewsOld/Shared/...