| ASP.NET Core | Express.js | Django | |
|---|---|---|---|
| Registration | app.Use(...) calls, in order | app.use(...) calls, in order | MIDDLEWARE list, in order |
| Pass to next layer | await next() | next() | get_response(request) |
| Short-circuit | Don't call next(); write a response instead | Don't call next(); call res.send() instead | Return a response without calling get_response |
| Error handling | try/catch around await next(), or UseExceptionHandler | Four-parameter (err, req, res, next) middleware | process_exception hook, or a try/except around get_response |
| Per-route middleware | app.Map(...) branches, or endpoint filters | Extra args in a route definition | Decorators (@login_required) on the view itself |
| Order sensitivity | Yes — auth before authorization, always | Yes — same reasoning | Yes — listed top to bottom |