Nancy.ViewEngines.ViewNotFoundException:无法定位视图';index.csh
本文关键字:index csh 视图 定位 ViewNotFoundException ViewEngines Nancy | 更新日期: 2023-09-27 18:21:53
体验此处描述的问题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",但报告的错误基本相同(您只需在消息中的index后面看到.cs.html)。注意缺少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)
确保您有有效的剃刀配置https://github.com/NancyFx/Nancy/wiki/Razor-View-Engine