web api restful routing not working

时间:2014-06-18 16:43:17

标签: c# rest routing

我有这个Web API路线:

config.Routes.MapHttpRoute(
           name: "CustomerSearchApi",
           routeTemplate: "api/{controller}/{action}/{criteria}",
           defaults: new { criteria = RouteParameter.Optional });

这有效:

http://localhost/api/CustomerSearch/Search?criteria=sdasd

这不是:

http://localhost/api/CustomerSearch/Search/sdasd

这是我的CustomerSearchController签名:

[HttpGet]
public HttpResponseMessage Search(string criteria)

有人可以告诉我原因吗?

0 个答案:

没有答案