Asp.Net Web Api multiple get methods -
i trying find routing configuration apicontroller having multiple methods.
the controller class has 3 methods:
public function getallproducts() ienumerable(of product) public function getproductbyid(prodid integer) product public function getproductbycategory(categoryname string) product
please suggest routing configuration needed 3 methods.
we follow web api design guidelines apigee, collections of patterns used in several , succesful web apis around world.
the guideline suggest chart bellow organize web api resources, ideal scenario keep 2 base urls resource:
in specific case, resource "product", suggest bellow urls:
- /products
- /products/{id}
- /products?cagetoryname={categoryname}
and web api table routes can configurated easy, like:
routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional, action = routeparameter.optional });
Comments
Post a Comment