【发布时间】:2013-05-16 13:04:27
【问题描述】:
我正在为 WebApi 使用 http://attributerouting.net/ nuget 包。这是我的两个 GET 方法和路由属性,用于列表和特定项目:
[GET("api/products/{tenantid}/{channelid}?{skip=0}&{take=20}&{status=1}")]
public IEnumerable<Product> Get(short tenantId, byte channelId, int status, int skip, int take)
[GET("api/products/{tenantid}/{channelid}/{id}")]
public Story Get(short tenantId, byte channelId, long id)
但在生成的帮助 URI 中,显示了三个 GET 选项。
GET api/products/{tenantid}/{channelid}?status={status}&skip={skip}&take={take}
GET api/products/{tenantid}/{channelid}?id={id}
GET api/products/{tenantid}/{channelid}/{id}
即使“id”不是第一个 GET 方法的参数。如何消除末尾带有“?id = {id}”的中间URI?我想我需要某种约束,但我无法从文档站点中弄清楚。
【问题讨论】:
标签: asp.net-web-api attributerouting asp.net-mvc-apiexplorer