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

前端 未结 17 1759
孤独总比滥情好
孤独总比滥情好 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:18

    I just added the Query key (Refit lib) in the property for the request.

    [Query(CollectionFormat.Multi)]

    public class ExampleRequest
    {
           
            [FromQuery(Name = "name")]
            public string Name { get; set; }               
           
            [AliasAs("category")]
            [Query(CollectionFormat.Multi)]
            public List Categories { get; set; }
    }
    

提交回复
热议问题