2

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?

4
  • Autofac is a good Ioc for Web Api. It's worth the try. Commented Dec 3, 2014 at 11:42
  • I agree. We went with StructureMap since the other teams are using it. Commented Dec 3, 2014 at 11:47
  • Autofac is far better in documentation than structuremap, most of the structuremap examples are old and useless for version 3 for example. Commented Dec 3, 2014 at 11:55
  • I have noticed that as well. Commented Dec 3, 2014 at 11:56

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

I have previously successfully used Ninject and Autofac. Since other teams here are using StructureMap this was the natural choice. Maybe it is time to reconsider :)
Maybe in time StructureMap will offer a Web API version, until then you are sadly stuck with some other solution.
Could the answer here be a workaround for now? Or will it require the same dependencies?stackoverflow.com/questions/18896758/…
The dependencies will be the same. You could try to remove the reference yourself but who knows. I still consider that you'll be better off with a solution made for Web API.
Ok. Yes, I will go with Autofac instead.
0

Autofac is a good Ioc for Web Api, and Autofac is far better in documentation than structuremap, most of the structuremap examples are old and useless for version 3 for example.

  • Here, you can find a quick start for using Autofac.
  • Here, you can find a good start-up for using Autofac with OWIN.

Hope that helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.