ASP.NET Core MVC/WebAPi 模型绑定
2021-07-03 04:04
标签:cli person res url .net from action ica web ASP.NET Core MVC/WebAPi 模型绑定 标签:cli person res url .net from action ica web 原文地址:https://www.cnblogs.com/earlymoon/p/9903214.html1 public class Person
2 {
3 public string Name { get; set; }
4 public string Address { get; set; }
5 public int Age { get; set; }
6 }
1 $("#btnJson").on("click", function () {
2 var datajson = { Name: "Jeffcky", Age: 24, Address: "湖南省" };
3 console.log(datajson);
4 $.ajax({
5 url: "../api/WebAPi/PostPerson",
6 contentType: "application/x-www-form-urlencoded;charset=utf-8",
7 dataType: "json",
8 type: "post",
9 data: datajson,
10 success: function (data) {
11 console.log(data);
12 }
13 });
14 });
1 [HttpPost]
2 public IActionResult PostPerson([FromBody]Person p)
3 {
4 return Json(p);
5 }
上一篇:一个从没见过的C# ?.语法
文章标题:ASP.NET Core MVC/WebAPi 模型绑定
文章链接:http://soscw.com/index.php/essay/101088.html