Pass Array into ASP.NET Core Route Query String

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

    I found two problems in your question:

    1. Your query has parameters named arr while you Contrller's Action has values.
    2. I don't know why, but you gotta name your parameter (as answered here) so the Asp .NET ModelBinder can work as expected. Like this:
    public void DoSomething([FromQuery(Name = "values")] string[] values)
    

    After doing that, everything should work as expected.

提交回复
热议问题