【发布时间】:2015-03-07 05:13:32
【问题描述】:
我正在通过 nuget 使用最新的 NancyFX,并且还通过 nuget 安装了 Razor 视图引擎,因为 SSVE 不适合我的需要(我需要更多条件逻辑选项)。
问题在于,每当我调用 Razor 视图时,我所能得到的只是 500 错误:
Nancy.RequestExecutionException: Oh noes! ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Nancy.ViewEngines.DefaultViewCache.GetOrAdd[TCompiledView](ViewLocationResult viewLocationResult, Func`2 valueFactory)
at Nancy.ViewEngines.Razor.RazorViewEngine.GetOrCompileView(ViewLocationResult viewLocationResult, IRenderContext renderContext, Assembly referencingAssembly, Type passedModelType)
at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
at CallSite.Target(Closure , CallSite , RazorViewEngine , ViewLocationResult , IRenderContext , Assembly , Object )
at Nancy.ViewEngines.Razor.RazorViewEngine.GetViewInstance(ViewLocationResult viewLocationResult, IRenderContext renderContext, Assembly referencingAssembly, Object model)
at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
at Nancy.ViewEngines.Razor.RazorViewEngine.<>c__DisplayClass27.b__26(Stream stream)
at Nancy.Responses.MaterialisingResponse.PreExecute(NancyContext context)
--- End of inner exception stack trace ---
at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex)
我在这里调用视图:
return View["Content/views/IO/fileBrowser/ViewPage2.cshtml", dirListing];
在此之前没有错误。
视图完全空白,根本没有代码。我还尝试查看指定布局的新视图,仍然是 500 错误。我尝试过引用我正在传递的模型,也尝试过不传递模型。全部都是一样。你打算如何将 Razor 与 Nancy 一起使用?什么是空引用?..
南希的超级有趣的道路对我来说不过是沮丧,没有什么是开箱即用的:(
【问题讨论】: