Developing OWIN-compliant Web Apps With Katana


Friday 19 Jul 2013 at 23:00
UserGroup  |  web

This post is a write-up of a user group session at DareDevs on 19th July 2013, delivered by Damien Hickey

  • With OWIN, you can host HTTP services in your own application, "in the box".
  • OWIN stands for "Open Web Interface for .NET".
  • OWIN is a specification, not a technology. It decouples the server (i.e. IIS) from applications and frameworks and it defines the minimum interface required to perform that decoupling.
  • It's composable. You can use your own authentication mechanism and other "middleware" within the processing pipeline.
  • At its core, OWIN is a simple "AppFunc". Any application that has Func<IDictionary<string, object>, Task> as an entry point is OWIN-compliant.
  • The IDictionary<string, object> is the environment dictionary. It stores request and response streams and it's mutable (to allow for compression etc). The environment also holds things like request headers and data. It's generally comparable to HTTPContext in the ASP.NET world.
  • Katana is a codename for Microsoft's implementation of OWIN. It's an .exe file - sort of a replacement for webdev.exe
  • The simplest code inside of a Sub Main() of a console app could be something like:
private void Main()
{
    using(WebApplication.Start())
    {
        ...
    }
}
  • The WebApplication.Start() will discover the entry point within the same assembly that exposes the "AppFunc".
  • OWIN offers great testability. You can test a complete request/response cycle through the complete pipeline using the built-in test server, which is a complete webserver that operates entirely within memory.