自定义ActionResult文件路径

时间:2011-12-15 21:13:13

标签: asp.net-mvc asp.net-mvc-3 razor asp.net-mvc-routing

当我尝试这样做时:

    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位于共享文件夹中时,一切正常。

但我需要它在Themes文件夹中!我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

您需要将<system.web.webPages.razor>部分从~/Views/Web.config复制到~/Themes/Web.config

有关详细信息,请参阅my blog post

相关问题