Introducing OWINIf you never heard about OWIN, I'll introduce it quoting what appear in the website:
OWIN defines a standard interface between .NET web servers and web applications.
Most of peoples (included me first time) would think immediately to a new open source web stack. But it would be wrong.
OWIN is a specification and hence never an implementation will be the official one.
At the moment of writing it is one year old; so more time passes and more it is possible that some implementations become reference implementations (but this is something completely different).
To clarify I'll post the remaining introductory explanation:
The goal of the OWIN interface is to decouple server and application, encourage the development of simple modules for .NET web development, and, by being an open standard, stimulate the open source ecosystem of .NET web development tools.
Anyway the intent of this article is not to deepen every aspect (it would take a book), but I want just to share with you the path that made me easier to understand this emerging specification, which I find very interesting.
So said that, how are defined OWIN data structures that let developers write applications, middleware and OWIN compliant-host? For a full reference please jump into full specification.
Here I'll present you how OWIN define an application:
using AppFunc = Func< IDictionary<string, object>, // Environment Task>; // Done
You do not depends on any particular assembly and any OWIN compliant-host must be able to load and execute your application.
But how looks a simple OWIN application? (Here, full GitHub project).
This application does nothing than printing some HTTP request headers when pointed by the browser.
As promised this post leaves to the reader further investigation on the subject. So how can you run this OWIN application?
Flux, an OWIN compliant-hostFlux is lightweight web server written in .NET using C# and implements the actual OWIN specification, hence we can say that it's an OWIN compliant-host.
It's author is Mark Rendle (author also of SimpleWeb framework) and you can find full sources on GitHub.
Running this post companion sample is very easy with Flux.
- clone and then build the sample repository
- git clone https://github.com/gsscoder/simpleowinapp.git
- clone and build also Flux
- git clone https://github.com/markrendle/Flux.git
- copy SimpleOwinApp.dll in same directory of the Flux.exe executable
- start Flux with the desidered port number
- flux 1234
- and finally point your browser on:
Flux relies on another project (of the same author) to locate and load assemblies that contains OWIN applications.
This project is named Fix and you can find it here.
This article and sample application was born on my personal investigation on OWIN that started with this thread on .NET HTTP Abstractions Group.
I hope that this can be a good starting point also for you.
Have fun with OWIN and Flux!