我是靠谱客的博主 知性酒窝,最近开发中收集的这篇文章主要介绍Multiple actions were found that match the request,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
Web API错误信息:
{"Message":"An error has occurred.","ExceptionMessage":"Multiple actions were found that match the request: rnSystem.Collections.Generic.IEnumerable`1[Lybing.Invoice.DataContract.Product] Get(Lybing.Invoice.Business.Model.ProductSearch) on type Lybing.Invoice.Web.ApiControllers.ProductControllerrnSystem.Collections.Generic.IEnumerable`1[Lybing.Invoice.DataContract.Product] GetAll() on type Lybing.Invoice.Web.ApiControllers.ProductControllerrnSystem.Collections.Generic.IEnumerable`1[Lybing.Invoice.DataContract.Product] Get() on type Lybing.Invoice.Web.ApiControllers.ProductController","ExceptionType":"System.InvalidOperationException","StackTrace":" at System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectAction(HttpControllerContext controllerContext)rn at System.Web.Http.Controllers.ApiControllerActionSelector.SelectAction(HttpControllerContext controllerContext)rn at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)rn at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessage request, CancellationToken cancellationToken)rn at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)"}
原来默认的API路由为:
routes.MapHttpRoute( name: "API Default", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });
修改routTemplate:
routes.MapHttpRoute( name: "API Default", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional });
恢复正常。
转载于:https://blog.51cto.com/lybing/1788000
最后
以上就是知性酒窝为你收集整理的Multiple actions were found that match the request的全部内容,希望文章能够帮你解决Multiple actions were found that match the request所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复