So I (and GPT) wrote a model binder that able to do it, but for one model (like [FromBody]
). not for two or more fields.
example of usage:
[HttpPost]
public IActionResult PostData([FormOrJson] ModelType model) {
if (!ModelState.IsValid) {
return BadRequest(ModelState);
}
// Process the model...
return Ok(new { model });
}
https://gist.github.com/MosheL/bd9edf2b2db0f7eb0ae554e482f28e7c