Multiple actions were found that match the request
Web API错误信息:
{"Message":"Anerrorhasoccurred.","ExceptionMessage":"Multipleactionswerefoundthatmatchtherequest:\r\nSystem.Collections.Generic.IEnumerable`1[Lybing.Invoice.DataContract.Product]Get(Lybing.Invoice.Business.Model.ProductSearch)ontypeLybing.Invoice.Web.ApiControllers.ProductController\r\nSystem.Collections.Generic.IEnumerable`1[Lybing.Invoice.DataContract.Product]GetAll()ontypeLybing.Invoice.Web.ApiControllers.ProductController\r\nSystem.Collections.Generic.IEnumerable`1[Lybing.Invoice.DataContract.Product]Get()ontypeLybing.Invoice.Web.ApiControllers.ProductController","ExceptionType":"System.InvalidOperationException","StackTrace":"atSystem.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectAction(HttpControllerContextcontrollerContext)\r\natSystem.Web.Http.Controllers.ApiControllerActionSelector.SelectAction(HttpControllerContextcontrollerContext)\r\natSystem.Web.Http.ApiController.ExecuteAsync(HttpControllerContextcontrollerContext,CancellationTokencancellationToken)\r\natSystem.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessagerequest,CancellationTokencancellationToken)\r\natSystem.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessagerequest,CancellationTokencancellationToken)"}
原来默认的API路由为:
routes.MapHttpRoute(name:"APIDefault",routeTemplate:"api/{controller}/{id}",defaults:new{id=RouteParameter.Optional});
修改routTemplate:
routes.MapHttpRoute(name:"APIDefault",routeTemplate:"api/{controller}/{action}/{id}",defaults:new{id=RouteParameter.Optional});
恢复正常。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。