简体   繁体   中英

Ninject for MVC5, WebApi2 using OWIN

I would like to use Ninject as the IoC container for a current project along with MVC5/WebApi2 pipelined via OWIN on IIS. However I've got a hard time in getting a clear picture about the numerous Ninject extensions, eg which are the prefered ones for such a setup, which ones are deprecated, which ones are actually required and which ones just provide a class or two that might not be necessary after all.

So we got...

  • Ninject.Web.Common
  • Ninject.Web.Common.OwinHost
  • Ninject.Web.Common.WebHost
  • Ninject.MVC5
  • WebActivatorEx (not part of Ninject, but a dependency)
  • Ninject.Web.WebApi.OwinHost (Ninject OWIN host for WebApi 2)
  • Ninject.Web.WebApi (Ninject integration for WebApi 2)

I'm especially confused because for MVC, I'm used to Ninject.MVC5, which requires Ninject.Web.Common and WebActivatorEx, however when utilizing OWIN, pipelining Ninject using Ninject.Web.Common.OwinHost seems to be the standard approach. Then again, Ninject.Web.Common.OwinHost doesn't seem to be compatible with OWIN v3, whereas Ninject.Web.WebApi.Owin (for WebApi 2) already is. Additionally, many of the packages are maintained by a dev called Remo Gloor (props to him for a genious MVC3 package!), however the 'official' ones are maintained by "Ninject Project Contributors".

Please, can anyone help me through this extension jungle to get a proper setup?

The following 2 links outline the requirements for hosting the WebApi portion in OWIN/IIS and making use of Ninject.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM