例如
//類 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