Api controller declaring more than one Get statement

后端 未结 2 927
失恋的感觉
失恋的感觉 2020-12-04 14:29

Using the new Api Controller in MVC4, and I\'ve found a problem. If I have the following methods:

public IEnumberable GetAll()

2条回答
  •  悲哀的现实
    2020-12-04 14:55

    In case someone else faces this problem. Here's how I solved this. Use the [Route] attribute on your controller to route to a specific url.

    [Route("api/getClient")]
    public ClientViewModel GetClient(int id)
    
    [Route("api/getAllClients")]
    public IEnumerable GetClients()
    

提交回复
热议问题