【发布时间】:2015-09-23 15:42:15
【问题描述】:
在我的 ApiController 中,我需要处理这些请求:
GET: api/User?role=theRole
GET: api/User?division=?theDivision
...
GET: api/User?other=stringValue
所有这些请求都可以通过如下方法处理:
public HttpResponseMessage Get(String stringParam)
但显然我不能使用重载...
我该如何解决这种情况?我应该使用带有可选参数的单一方法吗?
【问题讨论】:
-
您可以考虑将所有参数编码为一个:
GET: api/User?stringParam=role%20theRole .....
标签: c# .net asp.net-web-api