OWIN - not until ASP.NET MVC 6

Marcin Kawalerowicz / Monday, July 13, 2015

Hello, Infragistics Community! We are CODEFUSION, a small software development company from Opole, Poland, and this is the first of our posts for our friends at Infragistics.

For our summer internship program we are developing a custom monitoring service for web applications. As usual, in such cases it is an opportunity for our students to explore new directions that technology is taking. This time it was decided to go with the newest ASP.NET MVC 6 and possibly with OWIN/Katana. But do these things work together? Let’s see what our researchers found out:

OWIN

OWIN (The Open Web Interface for .NET) is an open source specification that defines an abstract layer (middleware) between a server and web application. OWIN's main goal is to simplify the creation of scalable components for server-based .NET web apps, by decoupling the web server and the application.

In effect, using the abstract layer implies two main elements. The first one is a dictionary environment which is responsible for keeping all HTTP reply and request states (header and bodies). This initialization looks like this:

IDictionary;

Here, the server fills up a dictionary and passes it to the application, which decouples the application from the server (application works directly with the dictionary and does not need to communicate with the server).

The second important thing in OWIN specification is the generic Func delegate. This delegate makes it possible for the server to be the main interface between all of the application components. This definition looks like this:

Func<IDictionary, Task>;

This Func delegate takes a dictionary environment as a parameter and returns a Task. This solution gives us:

  • Lesser dependency between components, thus developers can have greater access to OWIN.
  • Because the delegate is an atomic unit and the dictionary is sent as a parameter to this delegate, OWIN components can be easily connected creating HTTP complex message chains.

So to sum up, OWIN is not an implementation but a specification of how web frameworks and web servers interact with each other.

Katana

Katana is OWIN's open source implementation created by Microsoft. It has elements of infrastructures which are based on OWIN such as hosts and servers, but it has also its own unique components and functions, like authentication. It uses frameworks like SignalR, Nancy, and ASP.NET Web API.

OWIN's Katana Project has 2 main goals:

  • Portability - OWIN components should be easily added, removed or swapped out for a new one if we need it. Because of it, we can use third party frameworks on Microsoft's server, while Microsoft frameworks can be used on third party servers
  • Modularity - In contrast to frameworks where most options are enabled by default, Katana is focused on creating the simplest and the smallest components. It gives more control to developers over which components they want to use.

Why MVC doesn't work on OWIN (at least right now)

Unfortunately, MVC doesn't work on OWIN, because ASP.NET MVC is strictly dependent on System.Web, which is in conflict with OWIN's specification. In the future (ASP.NET vNext) this problem should be resolved by removing System.Web (creating unification of MVC with Web.API).

For more guesses and news articles about OWIN's future, take a look at some of the resources we've gathered here:

Supported components

Supported servers:

Supported frameworks:

  • Nancy
  • SignalR
  • WebApi
  • FubuMVC
  • Simple.Web
  • DuoVia.Http
  • ACSP.NET

Alternatives

NancyFx is an alternative for MVC. It is a framework that is compatible with OWIN. However NancyFx has got less tool support and created apps than MVC.

Tutorials

Articles and app examples that describe OWIN and Katana:

Sources:

  1. http://keyoti.com/blog/asp-net-v5web-apivnextowin-a-beginners-primer-part-1/
  2. http://benfoster.io/blog/nancy-vs-aspnet-mvc-getting-started
  3. http://davidfowl.com/asp-net-vnext/
  4. https://pl.wikipedia.org
  5. http://www.codeproject.com/Articles/826757/Understanding-OWIN-and-Katana
  6. http://stackoverflow.com/questions/20524060/how-to-explain-katana-and-owin-in-simple-words-and-uses
  7. http://typecastexception.com/post/2015/01/04/ASPNET-Understanding-OWIN-Katana-and-the-Middleware-Pipeline.aspx


[1] https://iobservable.net/blog/2013/08/01/owin-and-nginx/