首页 > Windows开发 > 详细

ASP.NET Core MVC/WebAPi 模型绑定

时间:2017-02-25 17:30:35      阅读:158      评论:0      收藏:0      [点我收藏+]
1  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         }

 

ASP.NET Core MVC/WebAPi 模型绑定

原文:http://www.cnblogs.com/early-moon/p/6442113.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!