カスタムビューエンジンをWebアプリにインストールする:
ViewEngines.Engines.Insert(0、new CustomViewEngine1()); ...そして2番目は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コレクションの次に来るView Engineを使用するために、コード(コメントがある場合)をどのように完成させることができますか?(これはデフォルトのMVC Razor Viewエンジンです)。
前もって感謝します。
よろしく。
ホセ