Pass an array of integers to ASP.NET Web API?

前端 未结 17 1735
孤独总比滥情好
孤独总比滥情好 2020-11-22 04:40

I have an ASP.NET Web API (version 4) REST service where I need to pass an array of integers.

Here is my action method:



        
17条回答
  •  礼貌的吻别
    2020-11-22 05:21

    You just need to add [FromUri] before parameter, looks like:

    GetCategories([FromUri] int[] categoryIds)
    

    And send request:

    /Categories?categoryids=1&categoryids=2&categoryids=3 
    

提交回复
热议问题