When working with .NET, I am encountering an issue where I need to send two sets of JSON data (test1 and test2) to a .NET controller using JavaScript (ajax). Here is the code snippet for sending the data:
.ajax({
type: 'POST',
url: "/test/test_Put/",
contentType: 'application/json; charset=utf-8',
data: {json_1:JSON.stringify(test1), json_2:JSON.stringify(test2)},
dataType:'JSON',
success:function(data){
},
error: function (data) {
}
});
The code for the .NET controller handling this request looks like this:
[HttpPost]
public JsonResult test_Put([FromBody]test1 tt1, [FromBody]test2 tt2){
}
However, I am facing errors in implementing this approach. How can I effectively handle this scenario in .NET?