Pass Array into ASP.NET Core Route Query String

前端 未结 8 1431
既然无缘
既然无缘 2020-12-05 04:28

I want to do this, but I want to also be able to pass in arrays into the query string. I\'ve tried things like:

http://www.sitename.com/route?arr[]=this&         


        
8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 05:00

    Given:

    public ValuesController
    {
        public IACtionResult Get([FromUri]string[] arr)
        {
            Return Ok(arr.Length);
        }
    }
    

    The following request will work:

    GET /api/values/?arr[0]=a&arr[1]=b&arr[2]=c
    

提交回复
热议问题