Reputation: 1314
From microsoft docs:
By default, model binding gets data in the form of key-value pairs from the following sources in an HTTP request:
- Form fields
- The request body (For controllers that have the [ApiController] attribute.)
- Route data
- Query string parameters
- Uploaded files
I'm intrested to know is there a way to add model binding from body data not using ApiControllerAttribute
.
The reason I ask this question is that we migrate from asp net 5 to net core 5 and we want to bind model parameters independet on with what content-type request comes: with content-type: x-www-form-urlencoded
or with content-type application/json charset=utf-8
I've read a lot about this problem but only found a decision to separate method for each content-type using [FromBody]
attribute as described in this article which doesn't fit me.
Upvotes: 0
Views: 327