Nancy.ViewEngines.ViewNotFoundException:无法找到视图'index.cshtml'

问题描述 投票:3回答:1

遇到此处描述的问题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)
c# razor nancy
1个回答
-1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.