所以我期待的是,当 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 编写代码。
请帮忙。
Smart猫小萌
相关分类