OWIN, Katana, ASP.NET Web API / MVC
This ASP.NET Web API poster is awesome!
tl;dr - It is very easy to write self-hosting C#/F# ASP.NET MVC/Web API application, without using any Visual Studio non-sense (templates, plugins, etc.)
Reading An overview of Project Katana (A HIGHLY RECOMMENDED READ) helped a lot understanding the relationship between the Microsoft web stack. OWIN is the spec laying out how to build middleware and web app in a chainable fashion. This is very similar to the apps concept in Express.js. Everything as small as authentication to as large as a web framework can be defined as a middleware.
Katana is an implementation of OWIN and related tools.
On top of this, you can then write ASP.NET MVC/Web API and host them as OWIN apps.
To self host a Web API app, there're two options,
- use OWIN selfhost (
Microsoft.Owin.SelfHost
) - use Web API home brew selfhoting (System.Web.Http.SelfHost)
If #2 is chosen, then it's completely separated from the OWIN stack.
- The core OWIN nuget package is
OWIN
- The core Katana nuget package is
Microsoft.Owin
- The OWIN self host package is
Microsoft.Owin.SelfHost
- The core ASP.NET Web API package is
Microsoft.AspNet.WebApi.Core
, but the assembly name isSystem.Web.Http
(so f**king confusing)
Useful documents for developing Web API and self hosting:
- To understand OWIN/Katana/ASP.NET: An overview of Project Katana
- Routing and Action Selection in ASP.NET Web API
- Configuring ASP.NET Web API 2
- Self-Host ASP.NET Web API 1
- Use OWIN to Self-Host ASP.NET Web API 2
- Media Formatters in ASP.NET Web API 2 (JSON)
Here's a vanilla Wep API application without any Visual Studio non-sense:
1 | namespace Foo |