我正在使用http://attributerouting.net/ nuget包的WebApi。這裏是我的兩個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?我想我需要某種約束,但我無法從文檔網站中找到它。
修復它。我甚至沒有考慮改變方法名稱。我應該認識到,切換到備用路由技術時,方法名稱不是路由約定的一部分。 – Dzejms