Creating OWIN middleware in .NET standard

Viewed 3806

TL;DR;

Is there a way to create an Owin middleware in .NET Standard that will be compatible backward with Microsoft.Owin?

Details

I created a simple middleware like:

public class RequestTrackingMiddleware
{
    private readonly RequestDelegate _next;

    public RequestTrackingMiddleware(RequestDelegate next)
    {
        _next = next;
    }

    public async Task Invoke(HttpContext context)
    {
        var sw = Stopwatch.StartNew();
        await _next(context);
        sw.Stop();
        Console.WriteLine(sw);
    }

I added it in "classic" ASP.NET app with Owin on the board. Using:

public override void Configuration(IAppBuilder app)
{
    app.Use<FinaiRequestTrackingMiddleware>();
}

But I end up with:

No conversion available between Microsoft.AspNet.Identity.Owin.IdentityFactoryMiddleware`2[....] and Microsoft.AspNetCore.Http.RequestDelegate.

Any ideas?

1 Answers
Related