Created
March 12, 2012 21:16
-
-
Save AlexZeitler/2024730 to your computer and use it in GitHub Desktop.
ASP.NET Web API nested route sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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