I'm just trying to get my head around relationship between webapi, webhost (iis) and owin. I'll write down my current understanding, and I ask you to tell me if it is correct or not.
我只是试图了解webapi,webhost(iis)和owin之间的关系。我会写下我目前的理解,并请你告诉我它是否正确。
- Webapi, unlike MVC was written in host-independent manner. This was in pre-Owin days, but apparently they anticipated that Owin would happen sooner or later. Host independency mainly means that System.Web is not used anywhere in Webapi code. It is System.Web that relies solely on IIS and would not work without it. This way Webapi could be theoretically hosted anywhere - once other hosts become available.
- 与MVC不同,Webapi是以独立于主机的方式编写的。这是在Owin之前的日子,但显然他们预计Owin迟早会发生。主机独立性主要是指在Webapi代码中的任何地方都不使用System.Web。 System.Web完全依赖于IIS,没有它就无法工作。这样,Webapi理论上可以在任何地方托管 - 一旦其他主机可用。
-
Webhost (
Microsoft.Owin.Host.SystemWeb
,Microsoft.AspNet.WebApi.WebHost
) is a layer to between a higher level API (such as Webapi) and the IIS. Since Webapi initially was host independent, an intermediate layer required to make it run on a particular host, such as IIS. Webhost for Webapi (Microsoft.AspNet.WebApi.WebHost
) provided this layer. Later on there will also be Webhost layer for Owin (Microsoft.Owin.Host.SystemWeb
), that would allow hosting anything Owin compatible on IIS. - Webhost(Microsoft.Owin.Host.SystemWeb,Microsoft.AspNet.WebApi.WebHost)是更高级API(如Webapi)和IIS之间的层。由于Webapi最初是独立于主机的,因此需要一个中间层来使其在特定主机(如IIS)上运行。 Webhost for Webapi(Microsoft.AspNet.WebApi.WebHost)提供了此层。稍后还会有Owin的Webhost层(Microsoft.Owin.Host.SystemWeb),它允许在IIS上托管任何Owin兼容的东西。
-
Owin came around the last. It basically provided an abstraction that theoretically would allow hosting any Owin compatible application on any host as long as there is a layer between owin and that host. Owin came with Webhost (
Microsoft.Owin.Host.SystemWeb
) (similar to how Webapi came with Webhost) that allowed Owin apps to be hosted on IIS. It also came with self-host (Microsoft.Owin.SelfHost
) that allowed Owin apps to be hosted inside any executable. As far as Webapi concerned, Owin also came with Owin host for Webapi (Microsoft.AspNet.WebApi.Owin
) which allowed running WebApi on Owin stack. - Owin绕过最后一个。它基本上提供了一个抽象,理论上允许在任何主机上托管任何Owin兼容的应用程序,只要在owin和该主机之间有一个层。 Owin附带了Webhost(Microsoft.Owin.Host.SystemWeb)(类似于Webapi带来的Webhost),允许Owin应用程序在IIS上托管。它还带有自托管(Microsoft.Owin.SelfHost),允许Owin应用程序托管在任何可执行文件中。就Webapi而言,Owin还为Owap主机提供了Webapi(Microsoft.AspNet.WebApi.Owin),允许在Owin堆栈上运行WebApi。
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.
以上所有意味着一个人有两种不同的方式在IIS上托管Webapi。它可以在没有Owin的情况下使用Webapi WebHost完成,也可以使用Owin Host for Webapi和Webhost for Owin完成。
Nuget references:
Nuget参考:
- Microsoft.Owin.SelfHost
- Microsoft.Owin.SelfHost
- Microsoft.Owin.Host.SystemWeb
- Microsoft.Owin.Host.SystemWeb
- Microsoft.AspNet.WebApi.WebHost
- Microsoft.AspNet.WebApi.WebHost
- Microsoft.AspNet.WebApi.Owin
- Microsoft.AspNet.WebApi.Owin
Is this understanding correct?
这种理解是否正确?
1 个解决方案
#1
13
Your understanding is generally correct, but the role of OWIN seems misunderstood. A more complete timeline would be:
你的理解通常是正确的,但OWIN的作用似乎被误解了。更完整的时间表将是:
- OWIN Standard developed to describe generic .NET web interface, a la WSGI/Rake/Connect (first commit in 2010).
- OWIN标准开发用于描述通用.NET Web界面,即WSGI / Rake / Connect(2010年首次提交)。
- ASP.NET WebAPI is developed host-independent, but released with https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/.
- ASP.NET WebAPI是独立于主机开发的,但随https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/一起发布。
- Katana Project implements several OWIN hosts:
- https://www.nuget.org/packages/Microsoft.Owin.SelfHost/
- https://www.nuget.org/packages/Microsoft.Owin.SelfHost/
- https://www.nuget.org/packages/Microsoft.Owin.Host.HttpListener/
- https://www.nuget.org/packages/Microsoft.Owin.Host.HttpListener/
- https://www.nuget.org/packages/Microsoft.Owin.Host.IIS/
- https://www.nuget.org/packages/Microsoft.Owin.Host.IIS/
- https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/
- https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/
- Katana Project实现了几个OWIN主机:https://www.nuget.org/packages/Microsoft.Owin.SelfHost/ https://www.nuget.org/packages/Microsoft.Owin.Host.HttpListener/ https:// www .nuget.org / packages / Microsoft.Owin.Host.IIS / https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/
- ASP.NET WebAPI adapter for OWIN is released: https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin.
- 发布了适用于OWIN的ASP.NET WebAPI适配器:https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin。
Your summary:
你的总结:
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.
以上所有意味着一个人有两种不同的方式在IIS上托管Webapi。它可以在没有Owin的情况下使用Webapi WebHost完成,也可以使用Owin Host for Webapi和Webhost for Owin完成。
I would restate that as:
我会重申:
All the above means that one has two different ways of hosting WebAPI. It can be done without Owin, using 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 is also provided.
以上所有意味着有一种托管WebAPI的两种不同方式。它可以在没有Owin的情况下使用WebAPI WebHost完成,也可以使用适用于WebAPI的OWIN适配器和任何与OWIN兼容的主机完成。 IIS上的托管选项是Microsoft.Owin.Host.IIS和Microsoft.Owin.Host.SystemWeb。还提供了Microsoft.AspNet.WebApi.OwinSelfHost。
#1
13
Your understanding is generally correct, but the role of OWIN seems misunderstood. A more complete timeline would be:
你的理解通常是正确的,但OWIN的作用似乎被误解了。更完整的时间表将是:
- OWIN Standard developed to describe generic .NET web interface, a la WSGI/Rake/Connect (first commit in 2010).
- OWIN标准开发用于描述通用.NET Web界面,即WSGI / Rake / Connect(2010年首次提交)。
- ASP.NET WebAPI is developed host-independent, but released with https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/.
- ASP.NET WebAPI是独立于主机开发的,但随https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/一起发布。
- Katana Project implements several OWIN hosts:
- https://www.nuget.org/packages/Microsoft.Owin.SelfHost/
- https://www.nuget.org/packages/Microsoft.Owin.SelfHost/
- https://www.nuget.org/packages/Microsoft.Owin.Host.HttpListener/
- https://www.nuget.org/packages/Microsoft.Owin.Host.HttpListener/
- https://www.nuget.org/packages/Microsoft.Owin.Host.IIS/
- https://www.nuget.org/packages/Microsoft.Owin.Host.IIS/
- https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/
- https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/
- Katana Project实现了几个OWIN主机:https://www.nuget.org/packages/Microsoft.Owin.SelfHost/ https://www.nuget.org/packages/Microsoft.Owin.Host.HttpListener/ https:// www .nuget.org / packages / Microsoft.Owin.Host.IIS / https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/
- ASP.NET WebAPI adapter for OWIN is released: https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin.
- 发布了适用于OWIN的ASP.NET WebAPI适配器:https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin。
Your summary:
你的总结:
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.
以上所有意味着一个人有两种不同的方式在IIS上托管Webapi。它可以在没有Owin的情况下使用Webapi WebHost完成,也可以使用Owin Host for Webapi和Webhost for Owin完成。
I would restate that as:
我会重申:
All the above means that one has two different ways of hosting WebAPI. It can be done without Owin, using 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 is also provided.
以上所有意味着有一种托管WebAPI的两种不同方式。它可以在没有Owin的情况下使用WebAPI WebHost完成,也可以使用适用于WebAPI的OWIN适配器和任何与OWIN兼容的主机完成。 IIS上的托管选项是Microsoft.Owin.Host.IIS和Microsoft.Owin.Host.SystemWeb。还提供了Microsoft.AspNet.WebApi.OwinSelfHost。