Is there any difference between using IApplicationBuilder of TMiddleware and IApplicationBuilder.Use()? In bot cases I can write elegant extension method and finnaly use
app.UseCustomMiddleware()
but I don't know the benefits of both approaches.
Is there any difference between using IApplicationBuilder of TMiddleware and IApplicationBuilder.Use()? In bot cases I can write elegant extension method and finnaly use
app.UseCustomMiddleware()
but I don't know the benefits of both approaches.
In the link,you can find "the app.Run delegates don't receive a next parameter. The first Run delegate is always terminal and terminates the pipeline."
And in the link,app.UseMiddleWare() can receive a next parameter.
app.UseMiddleWare(), Middleware is generally encapsulated in a class so that you can reuse the middleware, but for app.Use(),you put the code directly in Configure( IApplicationBuilder ) so you cannot reuse it.