Skip to content

Instantly share code, notes, and snippets.

@AlexZeitler
Created March 12, 2012 21:16
Show Gist options
  • Save AlexZeitler/2024730 to your computer and use it in GitHub Desktop.
Save AlexZeitler/2024730 to your computer and use it in GitHub Desktop.
ASP.NET Web API nested route sample
routes.MapHttpRoute("contacts", "api/contacts/{id}", new { controller = "Contacts", id = RouteParameter.Optional });
routes.MapHttpRoute("addresses", "api/contacts/{contactId}/addresses/{addressId}", new { controller = "Addresses", addressId = RouteParameter.Optional});
public class AddressesController : ApiController {
public List<Address> Get(int contactId) {
return new List<Address>();
}
public Address Get(int contactId, int addressId) {
return new Address();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment