2015-01-31 41 views
0

我試圖從Razor轉換爲Spark。Spark找不到我的模板

這裏是我的控制器:

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

但是星火提供了以下錯誤:

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

Why doesn't it realise that I've given it an absolute relative path?

好吧,可能是因爲沒有絕對的相對路徑。但是,這是旁邊點....

你還沒有做的是指定正確的路徑。在指定視圖的路徑時,您必須包含完整的名稱,最後我假設它有一個.spark。所以,你可以這樣做:

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

編輯:

它看起來像火花可能不理解斜線...所以嘗試反向:

return View(@"~\Views\Account\Index.spark"); 
+0

同樣的錯誤,但與... 'Home \〜/ Views/Index.spark.spark' – 2015-01-31 20:37:38

+0

@IanWarburton - 查看更新 – 2015-01-31 21:56:00

+0

同樣如此。似乎決定將控制器的名稱添加到路徑的開始處。 – 2015-01-31 23:59:47