Passing multiple parameters to web API GET method

柔情痞子 提交于 2019-11-28 14:37:06

You can pass a custom model to an action method, but I suggest not using the GET for you task because GET does not have a body.

Instead, use the SEARCH verb and put the list of serials number and the date inside a custom model in the body.

public class MeterSearchModel 
{
   public List<string> Serials {get;set;}
   public DateTime Date {get;set;}  
}

In .NET Core 2 your controller would have something like -

[AcceptVerbs("SEARCH")]
public async Task<IActionResult> Search([FromBody] MeterSearchModel model)
{
    //..perform search 
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!