How to do it...

As in the first recipe, we will do the following:

  1. Inject the ServiceProducts class by using a constructor in the HomeController of an ASP.NET MVC 6 application.
  2. Create a class called Product.
  3. Create an interface called IProductService.
  4. Create a class called ProductService.
  5. Modify HomeController to add a constructor that will inject IProductService.
  1. Create an action method called Products in HomeController.
  2. Create a view called Products.cshtml.
  3. Now, to use DryIoc, we will add the DryIoc and DryIoc.Dnx.DependencyInjection NuGet packages in project.json file's dependencies section. They will be downloaded automatically:

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.