Pass Array into ASP.NET Core Route Query String

前端 未结 8 1442
既然无缘
既然无缘 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:23

    In the end, I just passed in a single delimited string, then used string.Split to separate on the server side. Not the prettiest solution, but it works. Until someone comes up with a better answer, this is all I got. I should reiterate that I'm using .NET Core, and these query strings are framework specific.

    Update: An (arguable) benefit of this approach is that you pass the values together (e.g. arr=value1,value2) instead of repeating the key (arr=value1&arr=value2).

提交回复
热议问题