Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Web API:是否可以使用类型化参数进行AttributeRouting?_C#_Routing_Asp.net Web Api_Attributerouting - Fatal编程技术网

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的查询字符串。你知道我怎样才能让它工作吗?干杯