. Net WebApi development and. netwebapi Development
1. Create a project and select ASP.net MVC 4 Web Application
2. Select Web API
C
3. A generated webapi template is available in the newly created Project.
The WebApiConfig. cs and RouteConfig. cs files in the App_Start folder mainly configure the api routing information.
The files in the Controllers folder are api implementation files. ValuesController. cs is the sample api file.
4. Create your own webapi file.
Right-click the Controllers folder and choose add -- controller. We will create a file named TestApiController. cs. TestApi is the name of our Controller used in routing.
5. We add two new Get method APIs, one with and without Parameters
6. Configure the route path in the WebApiConfig. cs file: routeTemplate: "api/{controller}/{Action}/{id }",
Run the project and enter
Controller: TestApi
Action: name of the method we wrote
Id: input parameter
7. We can also write the Post method.