Durandal 入门套件和 Visual Studio 出现 404 错误

404 Error with Durandal Starter Kit and Visual Studio

我刚刚安装了 Durandal Starter Kit via Nuget and was hoping to start building Durandal apps using Visual Studio and the MVC framework. I've read a couple of articles and blog posts like this,但每当我尝试设置示例 Durandal 应用程序时,我都会收到 404 错误,浏览器会报错:'The resource can't be found.'

我已经检查过,Nuget 安装已经设置 DurandalController.cs 并删除了默认的 MVC 控制器。该项目是使用 'Empty' 模板创建的 'ASP.NET MVC 4 Web Application'。我做错了什么?

问题是 Durandal Starter Kit 的安装创建了一个新的默认控制器,但没有将其设置为项目的默认路由。

为了修复它,我导航到 App_Start/RouteConfig.cs 并在 RegisterRoutes() 中更改了默认值 routes.MapRoutefrom:

defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

至:

defaults: new { controller = "Durandal", action = "Index", id = UrlParameter.Optional }

此更改后应用程序立即运行。