I couldn't find an example of Owin Middleware for VB.Net anywhere. After much experimentation I came up with this simple example:
Public Class SimpleMiddleware
Inherits OwinMiddleware
Public Sub New(nextMiddleware As OwinMiddleware)
MyBase.New(nextMiddleware)
End Sub
Public Overrides Async Function Invoke(context As IOwinContext) As Task
Console.WriteLine("Hello OWIN")
Await Me.Next.Invoke(context)
End Function
End Class
To use it add the following to your Startup class
app.Use(GetType(SimpleMiddleware))