OWIN defines a standard interface between .NET web servers and web applications. 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.
To clarify and reword slightly, OWIN is a open source specification that is not defined by Microsoft and is not an actual implementation.
ASP.NET Core supports OWIN and defines middleware to be used in a request pipeline with the Microsoft.AspNet.Owin package.
ASP.NET Core NancyFX Demo
All of the source code for this demo is available on GitHub.
The first thing we are going to do for this demo is add the appropriate nuget packages.
Note: At the time of this post, ASP.NET Core is curently at RC1, which is still a pre-release and therfore you will need to include the “-Pre” option when installing any pre-release packages.
PM> Install-Package Microsoft.AspNet.Owin -Pre
PM> Install-Package Nancy
PM> Install-Package Nancy.Owin
Now in our Configuration method of our Startup class, there is a new extension method of UseOwin provided by the Microsoft.Asp.Net.Owin package, which allows us to include additional OWIN compatible middleware to our ASP.NET Core pipeline.
The Nancy.Owin package also provides an extension method UseNancy that we can use inside our UseOwn method.
For the demo, I’ve created a simple Nancy Module. Since Nancy will find it automatically (which is really nice) there is no registration needed.
Nancy does not support targeting .NET Core however does support Mono. You will have to remove the “dnxcore50” from frameworks section of the project.json
At this point, you are ready to run the demo. Your application should be hosted on port 5000. Calling http://localhost:5000/nancy/demo using Postman produces the expected output.
The ASP.NET Core documentation notes that you should not use multiple calls to UseOwin. Rather, insert all of your OWIN middleware grouped together within one UseOwin call.
The source code for this demo is available on Github.