gpt4 book ai didi

c# - 南希.ViewEngines.ViewNotFoundException : Unable to locate view 'index.cshtml'

转载 作者:行者123 更新时间:2023-11-30 18:46:25 26 4
gpt4 key购买 nike

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

具体来说,即使我按照我所理解的正确配置包括了 Razor View Engine,它也并不总是有效。自托管。

奇怪的是,我在我的 Mac(Mono/Xamarin 特定构建)或 2 台测试机器(windows/windows 构建)上没有遇到任何问题 - 它们工作得很好 - 但另外 2 台测试机器(windows/windows 构建)确实遇到了问题。

很难确定为什么会这样

使用.NET 4.5

肯定有 RAZOR 引擎 DLL 存在,甚至在 Bootstrap 中强制引用(并且没有抛出异常)

有什么线索吗?谢谢!

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

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)

最佳答案

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

关于c# - 南希.ViewEngines.ViewNotFoundException : Unable to locate view 'index.cshtml' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25819504/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com