.net core 传JSON对象Controller接收不到的问题处理方法

例如 

 //
    public class User1
    {
        public int id { get; set; }
        public string name { get; set; }
    }
//方法
        [HttpPost, Route("api/OrderPayJs/Notify0")]
      public string Notify0([FromBody]User1 u)
        {
            return "1";
        }
//传入参数
{
    id: 1,
    name: "冯东耀"
}

注意点

1 [FromBody]

2 传入参数id的传入类型要和类定义的类型一致,即 id为int型,传入时 id后的1 不可加双引号。

以上两点 如果不注意 ,则会转换对象失败,得到的对象是null

原文地址:https://www.cnblogs.com/simadi/p/13338079.html