1.HttpGet请求
①.一点参数
[HttpGet] public string TestGet(string name) { return name; }
②.一些参数(Test是自定义实体接收参数类)
[HttpGet] public string TestGet([FromQuery] Test test) { return test.name; }
2.HttpPost请求
①.前端传递序列化的参数 (contenttype:application/json,data:JSON.Stringfly(param))
[HttpPost] public string TestPost([FromBody] Test test) { return test.name; }
postman调用
②.Form表单提交(带图片的)
[HttpPost] public string TestPost([FromForm] Test test) { /*业务逻辑*/ return test.name; } public class Test { public string name { get; set; } public IFormFile file { get; set; }//图片 }
postman调用: