1.Post 方式,即使无参数,依旧需要加 [FromBody] 标签,否则会报错误 :在控制器“GetMongoIPCSetting”上找不到与该请求匹配的操作。
Post类型只能传递一个参数,且只能从Body中获取(加[FromBody]前缀)
[System.Web.Http.HttpPost] public SiWeiApiOperateResult GetMongoIPCSetting([FromBody]SiWeiApiOperateResult value) { var rlt = new SiWeiApiOperateResult<dynamic>(); return rlt; }
public string Get() { return "value"; } // POST api/<controller> public void Post([FromBody]string value) { } // PUT api/<controller>/5 public void Put(int id, [FromBody]string value) { } // DELETE api/<controller>/5 public void Delete(int id) { }