Web Api with Multiple Post in one Controller

  • 114 Views
  • Last Post 25 November 2016
  • Topic Is Solved
erportico posted this 25 November 2016

Hi All,

I have 2 post method in 1 controller.

[HttpPost]
public string Hello(string msg)
{
   return msg;
}
[HttpPost]
public string HelloAgain(string msg)
{
   return msg;
}

I have this error, when trying to call the api

Multiple actions were found that match the request

Can anyone tell me how to solved this one

/api/Msg/Hello

Thank you in advance!

admin posted this 25 November 2016

If you want to support action-based routing (that is, the action name is part of the URI), then you need to update your route on WebApiConfig under App_Start to

api/{controller}/{action}/{id}

  • Liked by
  • erportico
Close