I am posting data to my asp controller using fetch API with:
var data1 = {ID: '1', Name: 'John'},
data2 = {ID: '1',Action: 'Add'};
fetch('myController/MyAction',{method: 'post',body: JSON.stringify({data1: data1, data2: data2})});
I have my controller action like:
public async Task<IActionResult>MyAction([FromBody]Data1 data1, [FromBody]Data2 data2)
{
//break
//do something with data1
// do something with data2
}
I can see In Developer Tools, the data is being passed. But In VS debugger, I see both objects' all properties null. Please note that, if I send only data1 or data data2, model is bound successfully.