Spark无法找到我的模板

时间:2015-01-31 18:36:48

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

我试图将Razor转换为Spark。

这是我的控制器:

public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View("~/Views/Account/Index");
        }
    }

但Spark发出以下错误:

The view '~/Views/Account/Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
Home\~/Views/Account/Index.spark
Shared\~/Views/Account/Index.spark
Home\~/Views/Account/Index.shade
Shared\~/Views/Account/Index.shade 

为什么它没有意识到我给它一个绝对的相对路径?

1 个答案:

答案 0 :(得分:1)

  

为什么它没有意识到我给它一个绝对的相对路径?

好吧,可能是因为没有绝对的相对路径。但那不是重点......

您尚未执行的操作是指定正确的路径。指定视图的路径时,必须包含全名,我假设最后有一个.spark。所以你会这样做:

return View("~/Views/Account/Index.spark");

编辑:

看起来火花可能无法理解正斜线......所以请尝试反向:

return View(@"~\Views\Account\Index.spark");
相关问题