IEnumerable作为NET Core API的URI参数
在.NET Core 3.x中,接收IEnumerable作为NET Core API的URI参数,api,asp.net-core,.net-core,get,postman,Api,Asp.net Core,.net Core,Get,Postman,在.NET Core 3.x中,接收IEnumerable作为GET端点的URI参数的最佳方法是什么 在更深层的上下文中:我想做的是根据大量的guid过滤数据 到目前为止,我已经 [HttpGet] public ActionResult Get(int allowedMissing, IEnumerable<Guid> ids) . . . [HttpGet] public ActionResult Get(int-allowedMissi
IEnumerable
作为GET端点的URI参数的最佳方法是什么
在更深层的上下文中:我想做的是根据大量的guid过滤数据
到目前为止,我已经
[HttpGet]
public ActionResult Get(int allowedMissing, IEnumerable<Guid> ids)
.
.
.
[HttpGet]
public ActionResult Get(int-allowedMissing,IEnumerable-id)
.
.
.
我使用邮递员呼叫端点,如下所示:
/endpoint?allowedMissing=2&ids=cab0cfcb-8eb2-4313-8064-e7b0841d4f8a&ids=b2b944c2-6b4a-4c32-9a2f-472b891e4843
这会导致
415不受支持的媒体类型
,而不会在控制器内部命中任何断点。正常,因此在操作中接收IEnumerable
的默认值似乎在正文中
,如果作为查询发送,则需要使用FromQuery
来修饰参数
换成这个解决了我的问题:
[HttpGet]
public ActionResult Get(int allowedMissing, [FromQuery] IEnumerable<Guid> ids)
.
.
.
[HttpGet]
public ActionResult Get(int allowedMissing,[FromQuery]IEnumerable ID)
.
.
.