.net core api 接收参数
2021-05-16 05:29
标签:net ati ram data core loading form表单 type test postman调用 postman调用: .net core api 接收参数 标签:net ati ram data core loading form表单 type test 原文地址:https://www.cnblogs.com/MuZiLily/p/14577830.html1.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;
}
②.Form表单提交(带图片的)
[HttpPost]
public string TestPost([FromForm] Test test)
{
/*业务逻辑*/
return test.name;
}
public class Test
{
public string name { get; set; }
public IFormFile file { get; set; }//图片
}