Skip to content
Mike Evans-Larah By Mike Evans-Larah Software Engineer III
Introducing endjin composition framework 2.0 : Part 4 - ASP.NET MVC/WebAPI

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 best hour you can spend to refine your own data strategy and leverage the latest capabilities on Azure to accelerate your road map.

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.

Programming C# 10 Book, by Ian Griffiths, published by O'Reilly Media, is now available to buy.

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

Discover your Power BI Maturity Score by taking our FREE 5 minute quiz.

@MikeLarah

Mike Evans-Larah

Software Engineer III

Mike Evans-Larah

Mike is a Software Engineer at endjin with over 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.