webapi action 参数
使用地址参数传递(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; }