In CardsController, I have two post method written as below. I tried with /api/cards/card or /api/cards/cardlist and get exception message such as
"Multiple actions were found that match the request: \r\nSystem.Net.Http.HttpResponseMessage PostValue(Card) on type WebApiService.Controllers.CardsController\r\nSystem.Net.Http.HttpResponseMessage PostValue(CardList) on type WebApiService.Controllers.CardsController", "ExceptionType": "System.InvalidOperationException", "StackTrace": " at System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectAction(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)"
<HttpPost()>
<ActionName("card")>
Public Function PostValue(<FromBody()> ByVal value As Card_REQ.Card) As HttpResponseMessage
<HttpPost()>
<ActionName("cardlist")>
Public Function PostValue(<FromBody()> ByVal value As Cards_REQ.CardList) As HttpResponseMessage
In the Web.Config is configured as below.
config.Routes.MapHttpRoute( _
name:="DefaultApi", _
routeTemplate:="api/{controller}/{id}", _
defaults:=New With {.id = RouteParameter.Optional} _
)
config.Routes.MapHttpRoute( _
name:="DefaultApiWithAction", _
routeTemplate:="api/{controller}/{action}/{id}", _
defaults:=New With {.id = RouteParameter.Optional} _
)