Asp.net web api 通过通用列表<;int>;通过浏览器栏访问WebApi方法

Asp.net web api 通过通用列表<;int>;通过浏览器栏访问WebApi方法,asp.net-web-api,asp.net-mvc-routing,restful-url,Asp.net Web Api,Asp.net Mvc Routing,Restful Url,抱歉,如果您认为这是重复的,但它没有解决我的问题 我有一个WebApi方法,如: [AcceptVerbs("GET")] [ActionName("Search")] public EmpResults GetSearchResults([FromUri] string country, [FromUri] List<int> depts) { EmpResults emps = m_controller.Search(country, depts); return

抱歉,如果您认为这是重复的,但它没有解决我的问题

我有一个WebApi方法,如:

[AcceptVerbs("GET")]
[ActionName("Search")]
public EmpResults GetSearchResults([FromUri] string country, [FromUri] List<int> depts)
{
    EmpResults emps = m_controller.Search(country, depts);
    return emps;
}
我不知道如何通过简单的浏览器栏测试这个WebApi

我尝试了此方法并取得了一些成功,它返回了第10部门的员工列表:

http://localhost/WebApi.Employee/employee/search/brazil/10?connString=Provider...

但是我没能找到一个方法通过一个10、20、40等部门的名单。感谢您的帮助。

一种方法是删除路由中的
{depts}
,并在查询字符串参数中传递
depts

网址:

http://localhost/WebApi.Employee/employee/search/brazil?depts[]=10&depts[]=11&depts[]=12&connString=Provider…

路线:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapHttpRoute("IMO Route",
            "employees/search/{country}",
            new
            {
                controller = "Employee",
                action = "Search"
            });
} 

我确实尝试过这个方法,但我的缺点是,我没有更新路由以摆脱{depts}。谢谢你的解决方案。如果清单太大,比如说20-30项或更多,有什么替代方案。我应该去邮局吗?是的,对于这么大的收藏,我建议你用邮局。
public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapHttpRoute("IMO Route",
            "employees/search/{country}",
            new
            {
                controller = "Employee",
                action = "Search"
            });
}