← All posts
Architecture & Patterns50 min total · 13 parts
Middleware Pipelines Compared: ASP.NET Core, Express.js, and Django
Part 6 of 13 · ~1 min
Side by Side
| 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 | Skip next(); write a response directly | Skip next(); call res.send()/res.json() 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-level attributes | Extra arguments in a route definition | Decorators on the view function, read via process_view |
| What knows the resolved view | Endpoint metadata, visible to filters | The route definition itself | Only process_view — __call__ never sees it |
| Order sensitivity | Yes — auth before authorization, every time | Yes — identical reasoning | Yes — top to bottom, no exceptions |