后端
1 2 3 4 5 6 7 8 9 10 11 |
// POST api/<controller> public string Post([FromBody]List<User> value) { StringBuilder sb = new StringBuilder(); foreach (User user in value) { sb.AppendLine(user.Username); } return sb.ToString(); } |
前端
1 2 3 4 5 6 7 8 |
$.ajax({ method: "Post", url: "http://localhost:37085/api/ValList", data: { <strong>"":</strong> [{ "Id": 1, "Username": "w3cnet" }] }, success: function(result) { console.log(result); } }); |