属性路由不起作用

时间:2013-07-02 12:58:53

标签: c# asp.net-web-api wcf-web-api

我是使用aspnet web api进行属性路由的新手。

public class UsersController : ApiController
{
    [GET("users/me/brands/{id}")]
    public IEnumerable<Brand> GetBrands(long id)
    {
        return _repository.FindByUser(id);
    }
}

但我无法达成此举动。我尝试过很多方法:

  1. http://example.com/api/users/brands/4
  2. http://example.com/api/users/brands?id=4
  3. http://example.com/users/brands?id=4
  4. http://example.com/users/brands/4
  5. PS:我也映射为[GET("api/users/me/brands/{id}")]

    我缺少什么?

1 个答案:

答案 0 :(得分:2)

使用MVC 4和4.5

的网络api路由中存在错误

可以找到完整的解释和解决方法

MVC 4.5 Web API Routing not working?