Answer the question
In order to leave comments, you need to log in
MVC 5 WebApi binding how to do it right?
It is required to write a lot of ApiController
The problem is that the models do not match
I have a model
public Model
{
public string Name { get; set; }
}
and Post comes (cannot change the request)
Name: ""
model: "objects"
name: "New"
I found that this transformation can be solved through IModelBinder
public Model Post([ModelBinder(typeof(ModelBinder))] Model model) I get
into bool BindModel (..)
but I can’t reach the parameters that came in.
Tell me a simple way to bind models if their fields do not match
and / or
how to create a Model with Name = name in BindModel
Answer the question
In order to leave comments, you need to log in
Bind the models the way they come. These will be your API models.
Then work either with them directly or do remapping in the database model.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question