To be able to change the view location, you need to implement the IViewLocationExpander
. The ExpandViewLocations
method returns an IEnumerable<string>
containing the different locations where to search, with
public class MyViewLocationExpander : IViewLocationExpander
{
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
yield return "/CustomViewFolder/{1}/{0}.cshtml";
yield return "/SharedFolder/{0}.cshtml";
}
public void PopulateValues(ViewLocationExpanderContext context)
{
}
}