在我的网络应用上安装了自定义视图引擎:
ViewEngines.Engines.Insert(0,new CustomViewEngine1()); ......第二个是Razor的默认MVC View Engine
拥有我的第一个视图引擎的定义:
public class CustomViewEngine1: RazorViewEngine
{
public CustomViewEngine1(): this(null)
{ }
public CustomViewEngine1(IViewPageActivator viewPageActivator)
{
ViewLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml", "~/../Framework.Web/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml", "~/../Framework.Web/Views/Shared/{0}.cshtml" };
MasterLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml", "~/../Framework.Web/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml", "~/../Framework.Web/Views/Shared/{0}.cshtml" };
PartialViewLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml", "~/../Framework.Web/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml", "~/../Framework.Web/Views/Shared/{0}.cshtml" };
FileExtensions = new string[] { "cshtml" };
}
protected override IView CreatePartialView (ControllerContext controllerContext, string partialPath)
{
if (controllerContext.RequestContext.HttpContext.Request.Browser.IsMobileDevice)
{
return base.CreatePartialView(controllerContext, partialPath);
}
else
{
//...What i have to put here in order to let the control to the next route engine in the collection ViewEngines.Engines
}
}
protected override IView CreateView (ControllerContext controllerContext, string viewPath, string masterPath)
{
if (controllerContext.RequestContext.HttpContext.Request.Browser.IsMobileDevice)
{
return base.CreateView(controllerContext, viewPath, masterPath);
}
else
{
//...What i have to put here in order to let the control to the next route engine in the collection ViewEngines.Engines
}
}
}
我如何完成代码(我有评论的地方),以便如果请求不是由移动设备制作,则使用ViewEngines集合中接下来的视图引擎? (这是默认的MVC Razor View引擎)。
提前致谢。
问候。
何