2

我正在开发“ Code Camper ”示例 SPA 应用程序。我在安装了 MVC 4 的 VS 2010 上运行该应用程序。但是我遇到了 LookupsController 的问题。

这是我得到的错误:

    "exceptionMessage":"Multiple actions were found that match the request: \r\nSystem.Collections.Generic.IEnumerable`1[CodeCamper.Model.Room] GetRooms() on type
 CodeCamper.Controllers.LookupsController\r\nSystem.Collections.Generic.IEnumerable`1[CodeC
amper.Model.TimeSlot] GetTimeSlots() on type 
CodeCamper.Controllers.LookupsController","exceptionType":"System.InvalidOperationException
","stackTrace":"   at System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectActio
n(HttpControllerContext controllerContext)\r\n   at 
System.Web.Http.Controllers.ApiControllerActionSelector.SelectAction(HttpControllerContext 
controllerContext)\r\n   at 
System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, 
CancellationToken cancellationToken)\r\n   at 
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessage 
request, CancellationToken cancellationToken)\r\n   at 
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request, 
CancellationToken cancellationToken)"
4

1 回答 1

3

我找到了答案!

当你创建一个 web api 项目时,默认情况下 global.asax.cs 中有这行代码

WebApiConfig.Register(GlobalConfiguration.Configuration);

我删除了它(正如我从 codecamper 的源代码中看到的那样),现在没有问题了!但我不知道为什么

于 2013-01-03T14:17:38.630 回答