使用地址参数传递(queryString)数据:eg:http://localhost:5063/WeatherForecast?age=123
/// <summary> /// GET方法 /// </summary> /// <returns></returns> [HttpGet(Name = "GetWea阿斯顿rFoasasst")] public IActionResult Get(int age) { if(age == 200) { return Ok("200Age"); }else if(age == 100) { return Ok("100age"); }else { return NotFound("出错了"); } }
使用资源地址传递数据 eg:http://localhost:5063/WeatherForecast/1/2
[HttpGet("{i1}/{i2}")] public int Add(int i1,int i2) { return i1 + i2; }
eg:http://localhost:5063/WeatherForecast/params1/1/params1/2
[HttpGet("params1/{i1}/params1/{i2}")] public int Add(int i1,int i2) { return i1 + i2; }
标签:webapi,params1,return,int,age,i2,i1,参数,action From: https://www.cnblogs.com/zhulongxu/p/17758129.html