I have an MVC Web API Get method that accepts a List<string>
as a parameter. I'm trying to access this method using simply the browser bar. How is this done? Using ../APIName?parameter1=value1¶meter2=value2&...
passes a single parameter between two ampersands as opposed to a list.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答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) {...}
The query string parameter should be of this format
.../APIName?parameter[]=value1¶meter[]=value2&...
.
Hope this helps.