2011-12-15 110 views
1

当我尝试这样做:自定义的ActionResult文件路径

public ActionResult Index(string page) 
    { 
     IndexViewModel model = new IndexViewModel(); 
     return ("~/Themes/_Layout.cshtml", model); 
    } 

它给我的错误The name 'model' does not exist in the current context在第一行@model InnodiaCMS.Models.Controllers.IndexViewModel

但是这一切都正常工作时_Layout.cshtml是在共享文件夹。

但我需要它在主题文件夹!我怎样才能做到这一点?

回答

1

您需要将<system.web.webPages.razor>部分从~/Views/Web.config复制到~/Themes/Web.config。请参阅my blog post

+0

哦,这是一个很容易解决的mvc问题xD谢谢!并感谢您的链接。 – BjarkeCK 2011-12-15 21:35:29