OWIN app.use vs app.run vs app.map

2019-04-04 01:31发布

问题:

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.

回答1:

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