質問

私のNancyfxサイトで、CSHTMLのRazorビュー、ASP.NET、IIS7を採用して、ローカルで元気に動作します。それは 'ASP.NET開発サーバー'と私のLocal CopyのIIS7を介してスタンドアロンのサイトとして、VS12を介して機能します。私は私の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.cshtmlHomeView.htmlに名前を変更し、その内容のすべてをhello world(HTMLタグなし)に置き換えました(テキストだけです)。これは問題なく役立った。その後、Text-only HomeView.htmlHomeView.cshtmlに名前を付けて再度変更しました。

最後に、そして絶望的に、.cshtml - > text/htmlをマッピングするサーバーにMIMEタイプを追加しましたが、実際には.cshtmlファイルを提供していないため、違いはありません。

406 Not Acceptableファイルから派生したコンテンツに対して、Nancy(またはおそらくIIS7)が.cshtml応答を返すのはなぜですか?

編集 ナンシートレースです。 HomeView.cshtmlが見つからないこと、またはRazor Viewエンジンが使用されていないことを示すようです任意の * .cshtmlファイルが見つかりません。

Currently available view engine extensions: sshtml,html,htm
.

これから内部ナンシー例外につながる:

Nancy.ViewEngines.ViewNotFoundException
.

まだ同じサイトファイルがローカルで実行され、Razor View Engineを正しく呼び出して、それ故にHomeView.cshtmlを見つけます。

私はまだ急降下しています。

_nancy trace

[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
.

役に立ちましたか?

解決

答えは簡単でした。私は

に必要でした

  • Nancy.ViewEngines.Razorパッケージ(NUGET)
  • をアンインストールする
  • Nancy.ViewEngines.Razorパッケージ(NUGET)
  • プロジェクトをきれいにする
  • 再コンパイル
  • 再デプロイ

Voila!私はその16時間前にそれをやったはずだと思います。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top