【问题标题】:Nancy.ViewEngines.ViewNotFoundException: Unable to locate view 'index.cshtml'Nancy.ViewEngines.ViewNotFoundException:无法找到视图“index.cshtml”
【发布时间】:2014-09-13 03:22:18
【问题描述】:

遇到这里描述的问题https://github.com/NancyFx/Nancy/issues/1528

具体来说,即使我根据我理解的正确配置包含了 Razor View Engine,但它并不总是有效。自托管。

奇怪的是,我在我的 Mac(Mono/Xamarin 特定版本)或 2 台测试机器(Windows/Windows 版本)上没有遇到任何问题 - 它们工作得非常好 - 但其他 2 台测试机器(Windows/Windows 版本)确实遇到了问题。

很难确定为什么会这样

使用 .NET 4.5

肯定存在 RAZOR 引擎 DLL,甚至在引导程序中强制引用(并且不会引发异常)

有什么线索吗?谢谢!

编辑 1:根据要求,这是完整的堆栈跟踪。我随后将其更改为显式 'index.cshtml' 但报告的错误基本相同(您只在消息中的索引后看到 .cshtml)。请注意缺少 cshtml 作为受支持的视图扩展

Nancy.RequestExecutionException: Oh noes! ---> Nancy.ViewEngines.ViewNotFoundException:     Unable to locate view 'index'
Currently available view engine extensions: sshtml,html,htm
Locations inspected: views/Home/index-en-US,views/Home/index,Home/index-en-US,Home/index,views/index-en-US,views/index,index-en-US,index
Root path: XXX
If you were expecting raw data back, make sure you set the 'Accept'-header of the request to correct format, for example 'application/json'
   at Nancy.ViewEngines.DefaultViewFactory.GetRenderedView(String viewName, Object model, ViewLocationContext viewLocationContext)
   at Nancy.ViewEngines.DefaultViewFactory.RenderView(String viewName, Object model, ViewLocationContext viewLocationContext)
   at Nancy.Responses.Negotiation.ViewProcessor.Process(MediaRange requestedMediaRange, Object model, NancyContext context)
   at Nancy.Responses.Negotiation.DefaultResponseNegotiator.NegotiateResponse(IEnumerable`1 compatibleHeaders, NegotiationContext negotiationContext, NancyContext context)
   at Nancy.Responses.Negotiation.DefaultResponseNegotiator.CreateResponse(IList`1 compatibleHeaders, NegotiationContext negotiationContext, NancyContext context)
   at Nancy.Responses.Negotiation.DefaultResponseNegotiator.NegotiateResponse(Object routeResult, NancyContext context)
   at Nancy.Routing.DefaultRouteInvoker.<>c__DisplayClass9.b__5(Task`1 completedTask)
   --- End of inner exception stack trace ---
   at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex)

【问题讨论】:

  • 该异常包含有关 Nancy 尝试在何处查找 index.hrml 的信息。你能看看那个并将信息添加到问题中吗?
  • 出了点问题:“当前可用的视图引擎扩展:sshtml,html,htm”

标签: c# razor nancy


【解决方案1】:

确保您有有效的剃须刀配置 https://github.com/NancyFx/Nancy/wiki/Razor-View-Engine

【讨论】:

    猜你喜欢
    • 2017-06-22
    • 2011-11-04
    • 2019-10-22
    • 2021-06-11
    • 1970-01-01
    • 1970-01-01
    • 2021-08-15
    • 2013-09-23
    • 1970-01-01
    相关资源
    最近更新 更多