The easiest way to integrate StructureMap 3 and ASP.NET Web Api 2 is quite simple. StructureMap has a NuGet package that does it, but it creates 5 new files in a project
and doesn’t solve the problem well.
This article gives an overview of why using the ‘IDependencyScope’ is not
the best solution.
The final solution looks like this
You then register it in the GlobalConfiguration, usually in the App_Start/WebApiConfig.cs file
And bam! Integration. The RegisterForDispose call also ensures that any IDisposable entities in your StructureMap configuration are properly disposed after a request.