C# Web API:是否可以使用类型化参数进行AttributeRouting?
这可能吗? 比如说,C# Web API:是否可以使用类型化参数进行AttributeRouting?,c#,routing,asp.net-web-api,attributerouting,C#,Routing,Asp.net Web Api,Attributerouting,这可能吗? 比如说, [GET("api/item/{id}/related")] public dynamic GetRelatdItemsById(string id, Filter filter) { // get items related by id and optionally filter by `filter` } 如果可能,应如何设置查询字符串 非常感谢。别客气。只是忘记了使用[FromUri]属性。:) 嗨,亚历克斯,刚刚偶然
[GET("api/item/{id}/related")]
public dynamic GetRelatdItemsById(string id, Filter filter)
{
// get items related by id and optionally filter by `filter`
}
如果可能,应如何设置查询字符串
非常感谢。别客气。只是忘记了使用
[FromUri]
属性。:) 嗨,亚历克斯,刚刚偶然发现了你的问题,但是没有{id}我无法让我的查询串工作。例如,我有一个GetUsers(int-id)/GetUserByUserName(stringusername)/GetUserByName(stringname)。但是,如果用户的username=1234或name=1234,则and数据库中可能有一个有效的1234 id,所有路由都将混淆。我想做的是为最后两个方法提供过滤器,以获取过滤api/users/?username=1234或api/users/?name=1234的查询字符串。你知道我怎样才能让它工作吗?干杯