1234567891011121314151617181920212223242526272829 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.AspNetCore.Mvc.Razor;
- namespace MySystem
- {
- public class TemplateViewLocationExpander : IViewLocationExpander
- {
- public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
- {
- /// <summary>
- /// view文件路径
- /// </summary>
- /// <value></value>
- string[] locations = {
- "/Areas/Admin/Views/Admin/{1}/{0}.cshtml",
- "/Areas/Admin/Views/Base/{1}/{0}.cshtml",
- "/Views/{1}/{0}.cshtml",
- };
- return locations.Union(viewLocations);
- }
- public void PopulateValues(ViewLocationExpanderContext context)
- {
- context.Values["template"] = context.ActionContext.RouteData.Values["Template"]?.ToString() ?? "Default";
- }
- }
- }
|