Enrutamiento de atributos de la API web, por tipo de contenido, en dot net core 2?
Me gustaría poder consumir JSON publicado o datos de formulario en la misma URL.
Tal como están las cosas, obtengo:
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 sugiere usar diferentes puntos finales, pero no puedo hacer eso en este caso.
https: //massivescale.com/web-api-routing-by-content-type sugiere una forma de hacerlo para asp.net, por ejemplo:
[ContentTypeRoute("api/test/bytype", "application/json")]
[ContentTypeRoute("api/test/bytype", "application/x-www-form-urlencoded")]
pero en .net core, no tenemos System.Web.Http.Routing. Tal vez se pueda portar para usar Microsoft.AspNetCore.Mvc.Routing ... pero ¿hay algo para reemplazar IHttpRouteConstraint
Mi pregunta: ¿algo como esto ya está integrado en .net core mvc?
Por ejemplo, en JAX-RS de Java, hay @Consumes ("application / json")