首页 > 编程知识 正文

dotnet 6,开源项目 net core

时间:2023-05-04 12:51:41 阅读:163639 作者:4191

**

Dotnet Core的[HttpGet]多参数**

1、使用FromRouteAttribute

//get method//singleparameterpubliciactionresultget (intid )/multiple parameter [ http get ({ id }/{ back end only } ] ssed 多参数[ http get (({ id }/{ first }/{ second } ) (]publiciactionresultget ) ) (second ) ) )。

https://localhost:8888/2

https://localhost :8888/2/first

3359 localhost :8888/2/first/second

2、从查询

//get method//single parameter [ http get (details ) ] publiciactionresultdetails (intid )/multiple parameter [ htiplepaplepater ] string first )/multiple parameters [ http get (details ) ]publiciactionresultdetails

//getrequestusingqueryparameters

https://localhost :8888/details? id=2

https://localhost :8888/details? id=2first=csharp

https://localhost :8888/details? id=2first=csharpsecond=mvc

3、模型绑定源

bindpropertiesattribute—thiscanbeappliedtoclassleveltodefinetheallpropertiesneedtomapwithttprequest

//modelasparameter [ bind properties ]公共类getrequest {公共intid { get; set; }public string FrontEnd { get; set; }public string BackEnd { get; set; }//get method [ http get ]公共获取任务(getrequest getrequest )在浏览器中发送获取请求

3359 localhost :8888/get action? id=2FrontEnd=csharpBackEnd=mvc?

我个人推荐fromquery方式。 这样可以清楚地知道要调用哪个函数

参考: https://www.telerik.com/blogs/how-to-pass-multiple-parameters-get-method-aspnet-core-MVC

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。