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:

  1. Install the NuGet package Microsoft.AspNetCore.MVC.
  2. Open the Startup.cs file from the root folder of the project in Visual Studio.
  3. Add the following statement under the ConfigureServices method to add the MVC service to our project
    public void   ConfigureServices(IServiceCollection   
services)
{
services.AddMvc();
}
  1. 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();
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset