Passing a List to an MVC Web API method using the browser bar

后端 未结 1 1057
北荒
北荒 2020-12-16 11:08

I have an MVC Web API Get method that accepts a List as a parameter. I\'m trying to access this method using simply the browser bar. How is this d

相关标签:
1条回答
  • 2020-12-16 11:33
    1. Make sure your parameter of your action method is marked as [FromUri]. By default the value is expected to be passed from the body of the request since it is a complex type.

      public List<string> Get([FromUri] List<string> parameter)
      {...}
      
    2. The query string parameter should be of this format .../APIName?parameter[]=value1&parameter[]=value2&....

    Hope this helps.

    0 讨论(0)
提交回复
热议问题