What's the difference among app.use
, app.run
, app.map
in Owin? When to use what? It's not straightforward when reading the documentation.
For app. Run , it adds a terminal middleware delegate to the application's request pipeline. For app. Use , it adds a middleware delegate to the application's request pipeline.
Run() is an extension method on IApplicationBuilder instance which adds a terminal middleware to the application's request pipeline. The Run method is an extension method on IApplicationBuilder and accepts a parameter of RequestDelegate.
The difference is, middleware defined using app. Use may call next middleware component in the pipeline. On the other hand, middlware defined using app. Run will never call subsequent middleware.
The Run Extension method is used for adding terminal middleware that means Adds a terminal middleware delegate to the application's request pipeline. This method takes two Parameters: app: The Microsoft. AspNetCore. Builder.
app.use
inserts a middleware into the pipeline which requires you to call the next middleware by calling next.Invoke().
app.run
inserts a middleware without a next, so it just runs.
With app.map
you can map paths, which get evaluated at runtime, per request, to run certain middleware only if the request path matches the pattern you mapped.
See docs for use
and run
and map
for more details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With