Skip to content
  1. We help small teams achieve big things.
  2. Our Technical Fellow just became a Microsoft MVP!
  3. We run the Azure Weekly newsletter.
  4. We just won 2 awards.
  5. We just published Programming C# 8.0 book.
  6. We run the Power BI Weekly newsletter.
  7. Our NDC London 2020 talk is now available online!
  8. We are school STEM ambassadors.
Mike Larah By Mike Larah Software Engineer II

To use endjin composition framework with an ASP.NET MVC 4/WebAPI application, firstly pull in the Endjin.Core.Composition.Web package from NuGet.

Following the steps from the previous posts, you can set up your interfaces, concrete types and installers. No further initialization is required though - the package includes extensions for configuring and initializing the container, and also an installer for your MVC and WebAPI controllers.

The installer looks for all MVC and WebAPI controllers in the solution and registers them into the container. The configuration initializes the container and sets it to be used by the dependency resolver for MVC and WebAPI.

So long as the composition web package is referenced, this configuration is all done automatically on application startup using WebActivator.

This now allows you to use interfaces as your controllers' constructor parameters.

As long as concrete types for these interfaces have been registered in the container, the dependencies will be resolved whenever a request is made against a controller.

In the next post, I will be looking at what happens if you haven't registered all dependencies, and how to debug the container.

@MikeLarah

Mike Larah

Software Engineer II

Mike Larah

Mike is a Software Engineer at endjin with almost a decade of experience in solving business problems with technology. He has worked on a wide range of projects for clients across industries such as financial services, recruitment, and retail, with a strong focus on Azure technologies.