什么时候应该使用OWIN武士刀? [英] When should I use OWIN Katana?

查看:219
本文介绍了什么时候应该使用OWIN武士刀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来OWIN和武士刀。我真的不明白我为什么要使用OWIN,而我可以使用 IIS 。为了简化,我的问题是:我怎么输,如果我跳过学习OWIN和使用IIS为我的网站

I am new to OWIN and Katana. I really don't get why I should use OWIN, while I can use IIS. To simplify, my question is: What do I lose if I skip learning OWIN and use IIS for my websites?

我GOOGLE了,但还没有一个简单的解释。有一些信息<一个href=\"http://stackoverflow.com/questions/18058799/owin-and-katana-why-decouple-the-application-from-the-server\">here,但他们用一些专业术语的短语,所以我无法理解。

I googled but there is not a simple explanation. There is some information here, but they use some jargon phrases so I cannot understand it.

推荐答案

在asp.net的WebAPI v2中,OWIN管道成为默认。它最终将成为在任何asp.net项目的标准管道。

In asp.net WebApi v2, the OWIN pipeline becomes the default. It is eventually going to be the standard pipeline under any asp.net project.

我不能把它比什么是这里写的好:<一href=\"http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana\">http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana

I cannot put it better than what is written here : http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana

一节的开放Web接口.NET(OWIN)的解释完全OWIN的目标。

The section "The Open Web Interface for .NET (OWIN)" explains perfectly the goals of OWIN.

如果没有OWIN,在asp.net位耦合到IIS与应用程序的通信方式。 OWIN抽象Web服务器和框架组件。这意味着,你的应用程序code现在都知道了OWIN接口,但不是被服务请求的Web服务器。

Without OWIN, the asp.net bits are coupled to the way IIS communicates with the application. OWIN abstracts web servers and framework components. That means that your application code will now be aware of the OWIN interface, but not of the webserver that is serving the request.

在返回时,应用程序可以更容易的主机和潜在整个平台/操作系统之间移植。例如,能够在控制台托管的应用程序或任何工艺允许单声道到主机它没有努力......(树莓派任何人)

In return, applications can be more easily ported between hosts and potentially entire platforms/operating systems. For example, the ability to host an application in a console or any process allows Mono to host it without efforts... (Raspberry Pi anyone)

的第二个方面是,它可以作为一个管道。

The second aspect is that it works as a pipeline.

您可以将Web服务器和应用程序之间的中间件(和你想要的多)。结果
这允许更多的模块化解决方案。您可以开发可再发行组件的中间件,可以影响请求/响应来/从你的应用程序,但要保持这些模块从应用code分开。

You can plug any middlewares (and as many as you want) between the webserver and your application.
This allows for more modular solutions. You can develop redistributable middlewares that can impact the request/response coming to/from your application, but keep these modules separated from the application code.

要说服自己,这种模块化方法的好处,看看为OWIN可用的NuGet包: HTTP:/ /www.nuget.org/packages?q=owin

To persuade yourself of the benefits of this modular approach, take a look at the nuget packages available for OWIN : http://www.nuget.org/packages?q=owin

很多这些包都是previously核心asp.net的功能,并已提取为中间件。结果
例如,添加支持登录使用各种OAuth的提供商变成一个基础设施的关注(中间件),也不需要为你的应用程序code的一部分了:

A lot of these packages were previously core asp.net functionality, and have been extracted as middleware.
For example, adding support to login using various OAuth providers becomes an infrastructure concern (a middleware) and does not need to be part of your application code anymore :

或者,如果你想被可爱的猫图片自动替换所有从您的网站图像,你可以做到这一点透明,以及:

Or if you want to automatically replace all the images from your website by cute cat images, you can do that transparently as well :

https://github.com/serbrech/Owin.Catify

编辑:这是现在可以作为的NuGet包: Owin.Catify

EDIT : It is now available as a nuget package : Owin.Catify!

这篇关于什么时候应该使用OWIN武士刀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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