私のNancyFXサイトは、cshtml razorビュー、asp.net、IIS7を採用しており、ローカルでは問題なく機能します。これは、「ASP.NET開発サーバー」に組み込まれているVS12を介して機能し、IIS7のローカルコピーを介してスタンドアロンサイトとしても機能します。web.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
リモートサーバーで実行されている他の非ナンシーサイトは正常に動作し、まったく同じ受け入れヘッダーを持っています。このサイトは、私が知る限り、同じAcceptヘッダーを持つリモートサーバーで正常に機能していました。
また、ステージングサーバーで次のテストを実行しました。
名前をに変更HomeView.cshtml
しHomeView.html
、そのすべてのコンテンツをhello world
(htmlタグなし、テキストのみ)に置き換えました。これは問題なく提供されました。次に、text-onlyの名前をにHomeView.html
戻しHomeView.cshtml
、406を再度取得しました。
最後に、必死になって、マップするサーバーにMIMEタイプを追加しました.cshtml
->しかし、実際にはファイルtext/html
を提供していないので、もちろん違いはありません。.cshtml
ナンシー(またはおそらくIIS7)がファイル406 Not Acceptable
から派生したコンテンツに対する応答を返すのはなぜですか?.cshtml
編集
ここにナンシートレースがあります。HomeView.cshtml
が見つからないか、Razor Viewエンジンが使用されていないため、 *。cshtmlファイルが見つからないことを示しているようです。
Currently available view engine extensions: sshtml,html,htm
これにより、内部ナンシー例外が発生します。
Nancy.ViewEngines.ViewNotFoundException
それでも、まったく同じサイトファイルがローカルで実行され、Razor Viewエンジンを正しく呼び出して、を見つけますHomeView.cshtml
。
私はまだ困惑しています。
_ナンシートレース
[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