【问题标题】:Custom ActionResult File Path自定义 ActionResult 文件路径
【发布时间】:2023-04-09 02:24:01
【问题描述】:

当我尝试这样做时:

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

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

但当 _Layout.cshtml 位于共享文件夹中时,一切正常。

但我需要它在主题文件夹中!我该怎么做?

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 哦,终于有一个mvc中的问题很容易解决xD谢谢!并感谢您的链接。
    猜你喜欢
    • 2017-06-19
    • 1970-01-01
    • 2011-10-11
    • 1970-01-01
    • 1970-01-01
    • 2013-12-05
    • 2017-10-18
    • 2017-01-10
    • 2014-09-06
    相关资源
    最近更新 更多