每次請求頁面時,我都需要選擇火花主控佈局。我試圖通過在OnActionExecuting
中設置一個ViewBag.Layout
值並在主佈局參考中引用此值。在渲染時動態選擇火花主控佈局
<use master="${ViewBag.Layout}"/>
然而,這是不行的,它好像火花沒有括號內處理的代碼不是代碼,但作爲一個字符串。我收到以下錯誤:
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
Layouts\${ViewBag.Layout}.spark
Shared\${ViewBag.Layout}.spark
有誰能告訴我這是爲什麼?或者讓我指出另一種做法呢?
感謝您的信息,我想這是不可能的,所以我選擇了另一種解決方案 – jcvandan 2012-02-02 15:56:21