如何使用spark和MVC渲染html页面?

时间:2013-10-02 13:17:59

标签: asp.net-mvc spark-view-engine

我正在尝试使用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)和NOT spark extension?

提前致谢!

1 个答案:

答案 0 :(得分:1)

如果您将Principal.html重命名为Principal.sparkPrincipal.html.spark应该修复它。

Spark不知道应该查找要呈现的.html个文件。我不建议告诉Spark处理所有.html文件,但是如果你真的想要,那么你可以实现自己的Custom IDescriptorFilterimplementation来改变Spark查看视图的方式 - 但就像我说的那样,我我不推荐它 - 我只是将.html文件重命名为.spark你想要Spark接收的文件

是否有理由不能重命名html文件扩展名?