- Vue Element-ui axios-post request, the Content-Type requested by axios default is application/json
- The .net core backend receives the parameters List<T> generic parameters, how can it be received correctly?
1. Unable to receive
- Front-end parameter value
/*Request parameter value*/ var data=[] ({ id:1, name:'aaa' }) ({ id:2, name:'bbb' }) ({ id:3, name:'ccc' })
- Backend code
[HttpPost] public JsonResult Data(List<entity> list) { return Json(new { c = 200, m = "test" }); } public class entity { public int id { get; set; } public string name { get; set; } }
2. What can be received
- Front-end parameter value
/*Request parameter value*/ var data={ length:0, list:[] } var list=[] ({ id:1, name:'aaa' }) ({ id:2, name:'bbb' }) ({ id:3, name:'ccc' }) = =list
- Backend code
[HttpPost] public JsonResult Data(entity entity) { return Json(new { c = 200, m = "test" }); } public class entity { public int length { get; set; } public List<model> list { get; set; } } public class model { public int id { get; set; } public string name { get; set; } }
This is the article about Vue and .net Core receiving List<T> generic parameters. For more information about receiving List<T> generic parameters, please search for my previous articles or continue browsing the following related articles. I hope everyone will support me in the future!