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 package Microsoft.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();
}
- We just enabled MVC in our project. Next, we will wire up MVC with our request pipeline by adding the following statement in the Configure method:
app.UseMvc();