I have five actions in my web api controller as follows.
http://localhost:1234/products
- to map getallproduct
action
http://localhost:1234/products/1
- to map getproductnyid
action
http://localhost:1234/products
- saveproduct
action (post)
http://localhost:1234/products/1/getcolor
- getproductcolorbyid
action
http://localhost:1234/products/1/getcost
- getproductcostbyid
action
I need only one custom routing url for this.
I have tried following routing but it appends action name in url(http://localhost:24007/product/GetProductByID/Id
) which i don't want.
config.Routes.MapHttpRoute(
name: "ProductRoute",
routeTemplate: "product/{action}/{productId}",
defaults: new { controller = "Product", productId= RouteParameter.Optional }
);