There are 2 ways of writing OWIN middleware in ASP.NET Core.
- Pure OWIN - usefull if you want to integrate with OWIN compatible module but not written in C#
- ASP.NET Core OWIN middleware
ASP.NET Core Middleware:
This type of middleware can be:
- delegate of
Func<HttpContext, Func<Task>, Task> - class with
IMiddleware imlementation
app.Use(async (context, next) =>
{
// Do work that can write to the Response.
await next.Invoke();
// Do logging or other work that doesn't write to the Response.
});
Pure OWIN Middleware:
This rather would be used to integrate with OWIN middlewares written in different language, so that ASP.NET Core implementation directly is not possible.