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:

enter image description here

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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -