0

Spark と MVC を使用してプレーンな html ビューをレンダリングしようとしていますが、次のエラーが発生します。

The view 'Principal.html' or its master could not be found. The following locations were searched: 
~/Views/Site/Principal.html.aspx 
~/Views/Site/Principal.html.ascx 
~/Views/Shared/Principal.html.aspx 
~/Views/Shared/Principal.html.ascx 
Site\Principal.html.spark 
Shared\Principal.html.spark

私のコントローラーには次のものがあります:

 public ViewResult Principal()
   { 
      return View("Principal.html");
   }

Global.asax の Start メソッドに spark engina を登録します。

protected override void Start()
{
    ...
    RegisterViewEngine(ViewEngines.Engines, RouteTable.Routes);
    RegisterRoutes(RouteTable.Routes);            
}

 private void RegisterViewEngine(ViewEngineCollection engines, RouteCollection routes)
 {
    SparkViewFactory engine = new SparkViewFactory();            
    RegisterFactory.DefaultRegister(IoCService.MyContainer, engine, routes);
    engines.Add(engine);
 }

レンダリングするページが html (Principal.html) であり、spark 拡張ではないことをどのように示すことができますか?

前もって感謝します!

4

1 に答える 1

1

またはに名前Principal.htmlを変更すると、修正されるはずです。 Principal.sparkPrincipal.html.spark

.htmlSpark は、レンダリングするファイルを探す必要があることを知りません。Spark にすべての.htmlファイルを処理するように指示することはお勧めしませんが、本当にやりたい場合は、独自のカスタムIDescriptorFilter実装を実装して、Spark がビューを検索する方法を変更することができます。代わりに、.htmlファイルの名前.sparkを Spark に取得させたい名前に変更するだけです

HTML ファイル拡張子の名前を変更できない理由はありますか?

于 2013-10-04T12:58:58.127 に答える