【问题标题】:Using Razor with Durandal gives 404将 Razor 与 Durandal 一起使用会产生 404
【发布时间】:2014-06-25 00:45:57
【问题描述】:

我正在尝试将 cshtml 与 Durandal 一起使用

我遵循了关于 http://bartwullems.blogspot.com/2014/03/durandaljs-enable-razor-views.html

main.js 被正确调用,但是当它去寻找视图时,我得到了错误。

未找到视图。通过路径“text!views/shell.cshtml”搜索“views/shell”。

在控制台窗口中我可以看到 404 错误

http://local /App/views/shell.cshtml 404(未找到)

路由已配置,我将 web.config 从 View 复制到 App/views 并且 DurandalViewController 也已到位。 我的 main.js 看起来像示例中的一个 只有最后一行是

 app.setRoot('viewmodels/shell');

__________________________________

结构有

  • App/viewmodels/shell.js
  • App/views/shell.cshtml
  • App/views/web.config

【问题讨论】:

    标签: razor durandal single-page-application


    【解决方案1】:

    您的问题将是 Asp.net 中的路由。 默认情况下,路由引擎很可能会在 http://localhost/views/shared/shell.cshtmlhttp://localhost/views/yourControllerName/shell.cshtml 中查找 shell.cshtml。您需要添加一个路由来告诉服务器端在哪里可以找到视图。

    【讨论】:

      【解决方案2】:

      嗨,

      有关信息,我遇到了类似的问题。

      一切都在本地运行,但是当我将解决方案部署到 Azure 网站时出现错误:
      未找到。通过路径“text!views/shell.cshtml”搜索“views/shell”。
      在我的情况下,它是 http 错误 500。

      解决方案是将文件从“shell”重命名为其他名称。我将它重命名为 base.cshtml(和 base.js)。看起来 shell.cshtml 无法在 Azure 上处理。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-31
        • 1970-01-01
        • 2015-03-08
        相关资源
        最近更新 更多