Webapi、Webhost和Owin的关系

Relationship between Webapi, Webhost and Owin

我只是想了解 webapi、webhost (iis) 和 owin 之间的关系。我把我目前的理解写下来,请你告诉我是否正确。

以上所有意味着在 IIS 上有两种不同的托管 Webapi 的方式。它可以在没有 Owin 的情况下使用 Webapi WebHost 来完成,也可以使用 Owin Host for Webapi 和 Webhost for Owin 来完成。

Nuget 引用:

这个理解正确吗?

你的理解大体上是正确的,但是好像对OWIN的作用理解有误。更完整的时间表是:

  1. OWIN Standard developed to describe generic .NET web interface, a la WSGI/Rake/Connect (first commit in 2010).
  2. ASP.NET WebAPI 是独立于主机开发的,但与 https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/ 一起发布。
  3. Katana 项目实现了多个 OWIN 主机:
    1. https://www.nuget.org/packages/Microsoft.Owin.SelfHost/
    2. https://www.nuget.org/packages/Microsoft.Owin.Host.HttpListener/
    3. https://www.nuget.org/packages/Microsoft.Owin.Host.IIS/
    4. https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/
  4. ASP.NET OWIN 的 WebAPI 适配器已发布:https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin

您的摘要:

All the above means that one has two different ways of hosting Webapi on IIS. It can be done without Owin, using Webapi WebHost, or it can be done with Owin Host for Webapi and with Webhost for Owin.

我会重申为:

以上所有意味着有两种不同的托管 WebAPI 的方式。它可以在没有 Owin 的情况下完成,还提供了使用 WebAPI WebHost, or it can be done with the OWIN adapter for WebAPI and any OWIN-compatible host. Hosting options on IIS are Microsoft.Owin.Host.IIS and Microsoft.Owin.Host.SystemWeb. Microsoft.AspNet.WebApi.OwinSelfHost