Simply add an attribute to the controller action
[Route("product/{productId}/customer")]
public IQueryable<Product> GetProductsByCustomer(int productId)
{
//action code goes here
}
this will be queried as /product/1/customer
and productId=1
will be sent to the controller action.
Make sure the one within '{ }' and the action parameter are same. productId
in this case.
before using this, you have to specify that you are using Attribute Routing by:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
}
}