在我的网络应用程序上安装了自定义视图引擎:
ViewEngines.Engines.Insert(0, new CustomViewEngine1()); ...第二个是 Razor 的默认 MVC 视图引擎
并定义了我的第一个视图引擎:
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 引擎)。
提前致谢。
问候。
何塞