流浪のwolf

卷帝

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

统计

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;
        }

 

posted on   朱龙旭的网络  阅读(4)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
历史上的今天:
2022-10-11 封装setItem 和 getItem 本地存储
2022-10-11 yarn serve 不能开启vue项目 the project seem to require yarn but isnot install
2022-10-11 vant 2 的 toast
2022-10-11 统一携带 token
2022-10-11 我的频道 推荐频道 和全部频道之间的关系
2022-10-11 yarn serve 开启项目服务失败 assets emit different content to the same filename
2022-10-11 使用 vuex 和 本地存储实现永久性token存在 并且在请求拦截统一添加headers token 避免重复代码
点击右上角即可分享
微信分享提示