406应当NancyFX网站试图服务器的剃刀的风景
-
13-12-2019 - |
题
我NancyFX网站,采用cshtml剃刀景,asp.net 和IIS7,工作只是现在本地。它的工作通过VS12建立在'ASP.NET 发展服务器,并且作为一个独立网站穿过我的地方复制的IIS7.我已确保我的网页。config包含正确的剃刀部分。
如果部署这个网站远程服务器(测试我的过渡和生活服务器)此后每URI返回的错误:
406 - Client browser does not accept the MIME type of the requested page.
我已经检查 Accept
头请求。在这里,他们是:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
其他非nancy的网站上运行的远程服务器工作正常,它们具有完全相同的接受标题。这个网站使用的工作现在远程服务器上有相同的接受标题尽我所能告诉。
我还做了以下考试在我登台服务器。
我重新命名我 HomeView.cshtml
要 HomeView.html
和替换其所有内容 hello world
(没有html标记,仅仅是文本)。这个是没有问题。然后我改名为文本只 HomeView.html
回到 HomeView.cshtml
并得到了406次。
最后,在绝望中,我增加了一个类型的服务器的地图 .cshtml
-> text/html
但是,当然它没有区别,因为我不实际的服务 .cshtml
文件。
为什么是Nancy(或许IIS7)返回 406 Not Acceptable
响应任何内容来自 .cshtml
文件?
编辑
这里是南希踪。这似乎表明,无论是 HomeView.cshtml
无法被找到,或者剃刀视的发动机是不是正在用这样 任何 *.cshtml文件将不会被发现。
Currently available view engine extensions: sshtml,html,htm
然后,这导致内部Nancy例外:
Nancy.ViewEngines.ViewNotFoundException
但恰恰相同的网站的文件的运行在当地做调用剃刀图发动机正确,因此找到 HomeView.cshtml
.
我仍然难倒。
_Nancy跟踪
[StaticContentConventionBuilder] The requested resource '/home' does not match convention mapped to '/Content'
[DefaultRouteResolver] Found exact match route
[DefaultRouteInvoker] Processing as negotiation
[DefaultRouteInvoker] Accept header: text/html;q=1, application/xhtml+xml;q=1, application/xml;q=0.9, */*;q=0.8
[DefaultRouteInvoker] Acceptable media ranges: text/html
[DefaultRouteInvoker] Invoking processor: Nancy.Responses.Negotiation.ViewProcessor
[DefaultViewFactory] Rendering view with name HomeView
[DefaultViewResolver] Resolving view for 'HomeView', using view location conventions.
[DefaultViewResolver] Attempting to locate view using convention 'views/Home/HomeView'
[DefaultViewResolver] Attempting to locate view using convention 'Home/HomeView'
[DefaultViewResolver] Attempting to locate view using convention 'views/HomeView'
[DefaultViewResolver] Attempting to locate view using convention 'HomeView'
[DefaultViewResolver] No view could be resolved using the available view location conventions.
[DefaultViewFactory] Unable to find view engine that could render the view.
[DefaultRouteInvoker] Processor threw Nancy.ViewEngines.ViewNotFoundException exception: Unable to locate view 'HomeView'
Currently available view engine extensions: sshtml,html,htm
Locations inspected: ,views/Home/HomeView,,Home/HomeView,views/HomeView,HomeView
Root path: D:\wwwroot\GoodPractice.uMentor\[DefaultRouteInvoker] Invoking processor: Nancy.Responses.Negotiation.ViewProcessor
[DefaultViewFactory] Rendering view with name HomeView
[DefaultViewResolver] Resolving view for 'HomeView', using view location conventions.
[DefaultViewResolver] Attempting to locate view using convention 'views/Home/HomeView'
[DefaultViewResolver] Attempting to locate view using convention 'Home/HomeView'
[DefaultViewResolver] Attempting to locate view using convention 'views/HomeView'
[DefaultViewResolver] Attempting to locate view using convention 'HomeView'
[DefaultViewResolver] No view could be resolved using the available view location conventions.
[DefaultViewFactory] Unable to find view engine that could render the view.
[DefaultRouteInvoker] Processor threw Nancy.ViewEngines.ViewNotFoundException exception: Unable to locate view 'HomeView'
Currently available view engine extensions: sshtml,html,htm
Locations inspected: ,views/Home/HomeView,,Home/HomeView,views/HomeView,HomeView
Root path: D:\wwwroot\GoodPractice.uMentor\[DefaultRouteInvoker] Unable to negotiate response - no processors returned valid response
解决方案
答案很简单。我只是需要
- 卸载的南希。Viewengines.剃刀包(NuGet)
- 安装的南希。Viewengines.剃刀包(NuGet)
- 清洁项目
- 重新编译
- 重新部署
瞧!我应该做的,16小时前我估计。