I'd like to be able to consume either posted JSON or form data at the same URL.
As things stand, I get:
fail: Microsoft.AspNetCore.Mvc.Internal.ActionSelector[1]
Request matched multiple actions resulting in ambiguity. Matching actions:
:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLDLB0LJCPJ4", Request id "0HLDLB0LJCPJ4:00000001": An unhandled exception was thrown by the application.
Microsoft.AspNetCore.Mvc.Internal.AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:
https://andrewlock.net/model-binding-json-posts-in-asp-net-core/ suggests using different endpoints, but I can't do that in this case.
https://massivescale.com/web-api-routing-by-content-type/ suggests a way to do it for asp.net, for example:
[ContentTypeRoute("api/test/bytype", "application/json")]
or
[ContentTypeRoute("api/test/bytype", "application/x-www-form-urlencoded")]
but in .net core, we don't have System.Web.Http.Routing. Maybe it can be ported to use Microsoft.AspNetCore.Mvc.Routing... but is there something to replace IHttpRouteConstraint
My question: is something like this already built into .net core mvc?
For example, in Java's JAX-RS, there is @Consumes("application/json")