How to get instance of dependency resolver in ASP.NET web API
.net, asp.net-web-api, c#, dependency-injection
Solution
Ignore what people are saying about being an anti-pattern. You won't get full DI coverage, especially with these young technologies. For example, at the time of writing, `NInject` has no support for injecting into middlewares.
To answer your question, the dependency resolver for a request is available through `HttpRequestMessage.GetDependencyScope()`. You can also use `HttpConfiguration.DependencyResolver` however beware that this one is not properly scoped for the request being executed.
I would recommend checking the documentation for the specific IOC implementation.
Problem
How can I get the dependency resolver instance in web api? In asp.net mvc I can do `DependencyResolver.Current`, is there an equivalent in web api?