The default URL structure of ASP.NET Web API defined into the WebApiConfig.cs file is like shown in the following Image.
In the Preceding routing structure, we can access the resource using Base url+API+ApiController which is by default defined in WebApiConfig.cs due of this reason all resources accessed using controller name because inside the controller not more than one method defined which having same HTTP verb like GET or POST . We can access the web API methods using following url structure with this default routing pattern .
Consider our REST Service URL will be http://localhost:56290/api/Home which is described as follows,
- http://localhost:56290: Is the base address of web API service, It can be different as per your server.
- API: It is the used to differentiate between Web API controller and MVC controller request .
- Home: This is the Web API controller name.
To overcome the preceding mentioned issue and allow multiple GET , POST methods in single web API controller class then you need to modify url structure which is defined inside the WebApiConfig.cs as shown in the following Image .
Now with preceding url pattern we can access web API methods base url +API+Controller+webApi method.
From all preceding examples and explanations we have learned how to use multiple GET POST methods in single web API controller class.
I hope this article is useful for all readers. If you have any suggestions, then please mention it in the comment section.