I am working on a web application using Asp.Net Core 3.1, i make ajax call(using axios library, method is POST):
<script>
axios({
url: '/home/test', // HomeController/Test Action
method: 'post',
data: {
abc: 123
},
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
</script>
in my HomeController i have appropriate action:
[HttpPost]
public IActionResult Test(string abc)
{
return Json(new { abc });
}
in this case binding doesn't work well even if i add [FromBody] attribute like:
[HttpPost]
public IActionResult Test([FromBody]string abc)
{
return Json(new { abc });
}
what is a solution in this case?