using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc.Razor; namespace MySystem { public class TemplateViewLocationExpander : IViewLocationExpander { public IEnumerable ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable viewLocations) { string[] locations = { "/Areas/Admin/Views/BsServer/{1}/{0}.cshtml", "/Areas/Admin/Views/MainServer/{1}/{0}.cshtml", "/Areas/Admin/Views/JobServer/{1}/{0}.cshtml", "/Areas/Admin/Views/CashServer/{1}/{0}.cshtml", }; return locations.Union(viewLocations); } public void PopulateValues(ViewLocationExpanderContext context) { context.Values["template"] = context.ActionContext.RouteData.Values["Template"]?.ToString() ?? "Default"; } } }