Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IEnumerable作为NET Core API的URI参数_Api_Asp.net Core_.net Core_Get_Postman - Fatal编程技术网

IEnumerable作为NET Core API的URI参数

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

在.NET Core 3.x中,接收
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)
.
.
.