Creating ASP.NET Web API services
Let's create or add ASP.NET Web API services to our My Todo application that we created in the last chapter. Our My Todo application was created using the Empty ASP.NET 5 template in Visual Studio 2015. When an empty project is created, it creates a lean web application. It does not include assemblies related to MVC or the Web API. So, we need to explicitly add the required assemblies or modules to implement the Web API in our application.
Adding and configuring an MVC service to the ASP.NET project
Since ASP.NET Core, the Web API, was merged with MVC, we need to add an MVC service to implement a Web API in our application:
- Install the
NuGet
packageMicrosoft.AspNetCore.MVC
. - Open the
Startup.cs
file from the root folder of the project in Visual Studio. - Add the following statement under the
ConfigureServices
method to add the MVC service to our project
public void ConfigureServices(IServiceCollection services) { services.AddMvc...