0

This question is probably debatable, but I think there should be a solution that has more advantages than the other.

If I have two controllers - UsersController and ContactsController and the corresponding URIs to them /api/users/ and /api/contacts/, I want to be able to select all the contacts that belong to a particular user like this:

GET /api/users/1/contacts/

So, my question is what the better approach is - to put the actual .NET method in the UsersController or in the ContactsController and why.

Yulian
  • 6,262
  • 10
  • 65
  • 92
  • I think, it is clear. You put your method in Contacts controller. Well, because you get contacts. User id is your criteria. But on the other side, not sure if that logic supported by `GET /api/users/1/contacts/` unless you configure specific routing. – T.S. Jan 24 '15 at 20:38
  • Yeap, you should just add an Route attribute to your .NET method and everything fits in perfectly. Thanks :) – Yulian Jan 25 '15 at 01:04

0 Answers0