Search code examples
asp.net-web-apistructuremapstructuremap3

StructureMap in ASP.NET Web API 2 without a reference to System.Web.Mvc


The StructureMap.WebApi2 package has a dependency to StructureMap.MVC5 which in return has a dependency to System.Web.Mvc.

As we are building a Web API-only project we don't want to include the System.Web.Mvc assembly.

Is it possible to use StructureMap in Web API 2 without this dependency?


Solution

  • Sadly no.

    StructureMap is made for MVC so it obviously depends on it.

    Why do you insist on using StructureMap though? All it does is DI and there are many other options to do DI in Web API, like Ninject and Unity.