所以我期待的是,当 Angular 6 应用程序使用 GET 方法请求时,将唯一标识符列表或数组作为参数发送到 ASP.NET Core Web API,然后 ASP.NET Core 将带来仅与数组相关的信息返回到 Angular 应用程序的唯一标识符。我的 Web API 代码看起来像这样。[HttpGet]public ActionResult GetByGuids(List<Guid> Guids){ // some code here... return Ok(_someService.someAction(Guids)); //Guids will be passed as a parameter to the function of service layer}根据我自己的研究,我无法将唯一标识符数组添加到正文中,因为这是 GET 方法。我必须添加 [FromQuery] 因为如果我在参数是数组或列表时不添加它会产生错误。如果 [FromQuery] 是处理这种情况的唯一方法,那么我不知道应该如何为 Angular 编写代码。请帮忙。
1 回答

Smart猫小萌
TA贡献1911条经验 获得超7个赞
更改List<Guid> Guids
为[FromQuery]List<Guid> Guids
:
public ActionResult GetByGuids([FromQuery]List<Guid> Guids)
然后,您可以将请求作为http://myserver/controller/GetByGuids?Guids=6d627994-dce5-487e-bd2c-d48c0311a2e0&Guids=29a76d51-3c44-4fde-a0f1-b1f34567175e
- 1 回答
- 0 关注
- 161 浏览
添加回答
举报
0/150
提交
取消