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.
2 Answers
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

- 13,104
- 2
- 44
- 56
When dealing with a request we use IApplicationBuilder. And we have four methods available to interact with a request:
- Use
- Run
- Map
- MapWhen
These are called Request Delegates.
Use:
Adds a middleware to the application pipeline and it can either pass the request to next delegate or it can end the request (short- circuit request pipeline). It is the most commonly used method to interact with middleware.
Map
We use Map to connect a request path with another middleware. That middleware can use any of the other mentioned request delegates.
MapWhen
Behaves almost the same as Map except that we can specify the detailed condition by using a HttpContext object. We could check for URL, headers, query strings, cookies, etc).
Run
Generate a response and short-circuit the request
Please also read this article for more information.

- 791
- 5
- 8