When should I use OWIN Katana? When should I use OWIN Katana?

解答1

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.

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

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

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.


When should I use OWIN Katana?
When should I use OWIN Katana?


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.

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

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

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

 

 解答2

A simpler version of that answer is that Katana is gong to fully replace System.Web assembly and the old ASP.NET pipeline, which gives you both better flexibility (use it in more scenarios and use only the parts you like) and performance.

So everyone should watch its evolution now and be ready to switch when it is finally completed.

Below is a diagram I drew to fill in the details Microsoft fails to include in this article.

When should I use OWIN Katana?
When should I use OWIN Katana?

OWIN is such a standard that it let application frameworks run upon it and forget about everything beneath it. On the other hand, OWIN itself utilizes various host adapters to make sure it can talk to the underlying web servers (IIS and many others).

I am now working with the Jexus web server author to investigate how we can write a host adapter to bridge OWIN/Katana and Jexus. We are really happy to learn that OWIN is flexible and highly customizable.

Reference: http://blog.lextudio.com/2014/06/why-owin-matters-a-lot-for-asp-net-developers/