2010-11-30 7 views
0

- 私を選択するために、カミソリのエンジンを使用して... 私のコードはjfar postに基づいており、カミソリのエンジンを使用して唯一の違い - 私...カスタムViewEngineレイザーと私のカスタムViewEngineを作成しようとしているマスターページを動的

  • _Admin.cshtml
  • _Modal.cshtml

そして、私のカスタムViewEからFindView方法:私は2 "masterpages" を持っていますngine:、ViewEngineResult .Viewは常にnullであり、生成されたビューは、常にマスターページに関係なく同じである

public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) 
{    
    if (controllerContext.HttpContext.Request.IsAjaxRequest()) 
     return base.FindView(controllerContext, viewName, "_Modal", useCache); 
    return base.FindView(controllerContext, viewName, "_Admin", useCache); 
} 

デバッグ...

私が強制した場合usecache = falseを 、それはビューを返しますが、私はそのエラーました:

The view at '~/Views/Car/Index.cshtml' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.

[InvalidOperationException: The view at '~/Views/Car/Index.cshtml' must derive from ViewPage, ViewPage<TModel>, ViewUserControl, or ViewUserControl<TModel>.] 
    System.Web.Mvc.WebFormView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +306227 
    System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115 
    System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 
    System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260 
    System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260 
    System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260 
    System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343 
    System.Web.Mvc.Controller.ExecuteCore() +116 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97 
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37 
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50 
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7 
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184 

任意の助けを?

おかげ

答えて

1

問題は、要求の異なる2種類の単一のキャッシュを使用していることです。あなたの質問に直接は触れていませんが、同様の問題について議論している以下の記事を見てください:http://www.hanselman.com/blog/ABetterASPNETMVCMobileDeviceCapabilitiesViewEngine.aspx

例外として、スタックトレースを投稿できますか?

+0

私はスタックトレースで編集しました... – Paul

関連する問題