Basics of OWIN and Katana

OWIN

 
A community-owned standard known as Open Web INterface (OWIN) for .Net is a standard interface between .NET web servers and web applications. The goal of OWIN is to decouple the server and application and to be an open standard and to stimulate the open-source ecosystem of .NET web development tools. OWIN is defined in terms of a delegate structure.
 
As per the sources from the ASP.NET website, OWIN was inspired by the benefits achieved by Rack in the Ruby community. Several members of the .NET community set out to create an abstraction between Web servers and framework components. An overview of the components of abstraction can be visualized as:
 
one server
 
The following are the components of this abstraction.
 
Server
The HTTP server directly communicates with the client and then uses OWIN semantics to process requests. Servers may require an adapter layer that converts to OWIN semantics.
 
Web Framework
A self-contained component on top of OWIN exposing its own object model or API that applications may use to facilitate request processing. Web Frameworks may require an adapter layer that converts from OWIN semantics.
 
Web Application
A specific application, possibly built on top of a Web Framework, that is run using OWIN compatible Servers.
 
Middleware
Pass-through components that form a pipeline between a server and application to inspect, route, or modify request and response messages for a specific purpose.
 
Host
The process an application and server execute inside of, primarily responsible for application startup. Some servers are also hosts. As a benefit of this abstraction, you'll be able to port or move your application from one server to another or port to a completely different platform and OS (Host). Let's visualize this in terms of technology existing on each layer. Now the diagram would become something like this: (Thanks to Lex Li to make it simple to understand for others here).
 
Porting
 
The resulting abstraction consists of two core elements. The first is the environment dictionary of type IDictionary<string, object>. This data structure is responsible for storing all of the states necessary for processing an HTTP request and response, as well as any relevant server state.
 
For a full list of Dictionary, items visit the specification here (see section 3.2).
 
The second key element of OWIN is the application delegate. This is a function signature that serves as the primary interface between all components in an OWIN application. The definition of the application delegate is as follows: 
  1. Func<IDictionary<stringobject>, Task>;  

Project Katana 

 
OWIN is a standard and the Katana is the project from Microsoft that represents the set of OWIN components. These components include both infrastructure components, such as hosts and servers, as well as functional components, such as authentication components and bindings to frameworks such as SignalR and the ASP.NET Web API. The project targets the following three goals as specified in the ASP.NET website page of the Katana project.
  1. Portable
  2. Modular/Flexible
  3. Lightweight/performant/scalable
Why Katana
 
Katana was developed to be a lightweight webserver like Node.js and it brings many benefits of Node.js and other frameworks like Node.js. If you understand Node.js then you can directly jump in with Katana since it is inspired by Node.js in nature.
 
In the next article, we will see how to create a simple application using Katana and discuss a little more about Katana.