Using the standard route:
config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );
Using these steps:
public class ValuesController : ApiController { // GET api/values public string GetAll() { return "all"; } // GET api/values/5 public string GetById(int id) { return "single"; } // GET api/values?ids=1&ids=2 public string GetByIds([FromUri] int[] ids) { return "multiple"; }
And make the request / api / values, I get this exception:
Multiple actions were found that match the request: System.String GetAll() on type MvcApplication4.Controllers.ValuesController System.String GetByIds(Int32[]) on type MvcApplication4.Controllers.ValuesController
I spun the wheels, trying to find a solution around this. I believe that the actions of GetAll and GetByIds are counted somewhat here, but they are not because GetByIds has a different signature. p>
Is there any work for this that does not include adding {action} to the route?
c # asp.net-web-api asp.net-web-api-routing
Levitikon
source share