Webapi,Webhost和Owin之间的关系 [英] Relationship between Webapi, Webhost and Owin

查看:309
本文介绍了Webapi,Webhost和Owin之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是试图了解webapi,webhost(iis)和owin之间的关系。我会写下我目前的理解,并请你告诉我它是否正确。

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 ,与MVC不同,是以独立于主机的方式编写的。这是在Owin之前的日子,但显然他们预计Owin迟早会发生。主机独立性主要是指在Webapi代码中的任何地方都不使用System.Web。 System.Web完全依赖于IIS,没有它就无法工作。这样,Webapi理论上可以在任何地方托管 - 一旦其他主机可用。

  • Webhost Microsoft.Owin.Host.SystemWeb Microsoft.AspNet .WebApi.WebHost )是更高级API(如Webapi)和IIS之间的层。由于Webapi最初是独立于主机的,因此需要一个中间层来使其在特定主机(如IIS)上运行。 Webapi的Webhost( Microsoft.AspNet.WebApi.WebHost )提供了此层。稍后还会有Owin的Webhost层( Microsoft.Owin.Host.SystemWeb ),这将允许在IIS上托管Owin兼容的任何东西。

  • 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。

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

以上所有意味着一个人有两种不同的方式在IIS上托管Webapi。它可以在没有Owin的情况下使用Webapi WebHost完成,也可以使用Owin Host for Webapi和Webhost for 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.

Nuget references:

Nuget references:

  • Microsoft.Owin.SelfHost
  • Microsoft.Owin.Host.SystemWeb
  • Microsoft.AspNet.WebApi.WebHost
  • Microsoft.AspNet.WebApi.Owin

这种理解是否正确?

推荐答案

您的理解通常是正确的,但OWIN的作用似乎被误解了。更完整的时间表是:

Your understanding is generally correct, but the role of OWIN seems misunderstood. A more complete timeline would be:


  1. OWIN开发用于描述通用.NET Web界面的标准,即WSGI / Rake / Connect(在2010年提交)。

  2. ASP.NET WebAPI是独立于主机开发的,但随 https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/

  3. Katana Project实现了几个OWIN主机:

  1. OWIN Standard developed to describe generic .NET web interface, a la WSGI/Rake/Connect (first commit in 2010).
  2. ASP.NET WebAPI is developed host-independent, but released with https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/.
  3. Katana Project implements several OWIN hosts:

  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 /

  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/


  • 发布了针对OWIN的ASP.NET WebAPI适配器: https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin

  • ASP.NET WebAPI adapter for OWIN is released: https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin.
  • 您的摘要:


    以上所有意味着有一种在IIS上托管Webapi的两种不同方式。它可以在没有Owin的情况下使用Webapi WebHost完成,也可以使用Owin Host for Webapi和Webhost for 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。可以使用 WebAPI WebHost 在没有Owin的情况下完成,或者它可以使用适用于WebAPI的OWIN适配器和任何与OWIN兼容的主机。 IIS上的托管选项是 Microsoft.Owin.Host.IIS 和< a href =https://www.nuget.org/packages/Microsoft.Owin.Host.SystemWeb/\"rel =noreferrer> Microsoft.Owin.Host.SystemWeb 。还提供了 Microsoft.AspNet.WebApi.OwinSelfHost

    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,Webhost和Owin之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆