一.aspx视图时
public class ADCViewEngine : WebFormViewEngine { public ADCViewEngine() { //Action找到View的规则 var formmats = new List<string>(); formmats.Add("~/Views/ProductHall/{1}/{0}.aspx"); formmats.Add("~/Views/ProductHall/{1}/{0}.ascx"); formmats.Add("~/Views/ExperienceCenter/{1}/{0}.aspx"); formmats.Add("~/Views/ExperienceCenter/{1}/{0}.ascx"); formmats.Add("~/Views/{1}/{0}.aspx"); formmats.Add("~/Views/{1}/{0}.ascx"); formmats.Add("~/Views/Shared/{0}.aspx"); formmats.Add("~/Views/Shared/{0}.ascx"); base.ViewLocationFormats = formmats.ToArray();//View页面规则 base.MasterLocationFormats = new string[] { "~/Views/{1}/{0}.master", "~/Views/Shared/{0}.master" };//母版页的规则 base.PartialViewLocationFormats = formmats.ToArray();//部分页面(用户控件)的规则 }
二.Razor视图public class ADCViewEngine :RazorViewEngine
{
public ADCViewEngine()
{ //Action找到View的规则 var formmats=new List<string>(); formmats.Add("~/Views/{1}/{0}.cshtml"); formmats.Add("~/Views/MemberOrder/{1}/{0}.cshtml"); formmats.Add("~/Views/Shared/{0}.cshtml"); base.ViewLocationFormats = formmats.ToArray();//View页面规则 base.MasterLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" };//母版页的规则 base.PartialViewLocationFormats = formmats.ToArray();//部分页面(用户控件)的规则 base.FileExtensions = new string[] { "cshtml", "vbhtml" }; }
}