为MVC5, WebApi2使用OWIN

时间:2022-02-05 13:26:51

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, e.g. 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.

我希望使用Ninject作为当前项目的IoC容器,以及通过IIS上的OWIN实现的MVC5/WebApi2管道。不过我有一个很难得到一个明确的众多Ninject扩展,如为这样的设置是优先的,哪些是弃用,哪些是必需的,哪些只是提供一个或两个类可能不是必要的。

So we got...

所以我们得到了…

  • Ninject.Web.Common
  • Ninject.Web.Common
  • Ninject.Web.Common.OwinHost
  • Ninject.Web.Common.OwinHost
  • Ninject.Web.Common.WebHost
  • Ninject.Web.Common.WebHost
  • Ninject.MVC5
  • Ninject.MVC5
  • WebActivatorEx (not part of Ninject, but a dependency)
  • WebActivatorEx(不是Ninject的一部分,而是依赖项)
  • Ninject.Web.WebApi.OwinHost (Ninject OWIN host for WebApi 2)
  • Ninject.Web.WebApi。OwinHost (Ninject OWIN主机,用于WebApi 2)
  • Ninject.Web.WebApi (Ninject integration for WebApi 2)
  • Ninject.Web。WebApi (WebApi 2的Ninject集成)

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".

我很困惑,因为对于MVC,我习惯了Ninject。需要Ninject.Web MVC5。普通的和WebActivatorEx,但是当使用OWIN,流水线使用ninject.net .Common。OwinHost似乎是标准的方法。话又说回来,Ninject.Web.Common。OwinHost似乎与OWIN v3不兼容,而ninjets . webapi。Owin(对于WebApi 2)已经是。此外,许多包都是由开发人员Remo Gloor维护的(这是他的MVC3包的道具!),但是“官方”包是由“Ninject项目贡献者”维护的。

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

拜托,有人能帮我通过这个扩展丛林找到合适的安装吗?

1 个解决方案

#1


2  

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

下面的两个链接概述了在OWIN/IIS中托管WebApi部分的需求,并使用Ninject。

#1


2  

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

下面的两个链接概述了在OWIN/IIS中托管WebApi部分的需求,并使用Ninject。