gpt4 book ai didi

asp.net-web-api - 在 asp.net web api 中找到了与请求匹配的多个操作

转载 作者:行者123 更新时间:2023-12-04 05:17:08 24 4
gpt4 key购买 nike

我正在研究“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)"

最佳答案

我找到了答案!

创建web api项目时,默认global.asax.cs中有这行代码

WebApiConfig.Register(GlobalConfiguration.Configuration);

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

关于asp.net-web-api - 在 asp.net web api 中找到了与请求匹配的多个操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14104148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com