Backend in .NET · Chapter 8
Middleware compared: ASP.NET Core, Express and Django
About this chapter
Almost every web framework passes a request through a chain of layers, though each names them differently and sets its own rules. Here the same experiments are repeated in ASP.NET Core, Express and Django to compare how layers wrap a request, answer it early, fail to hand it on, handle errors and wait on slow work. The chapter ends with what is worth putting in a layer and how to test one without a server.
Who it is for: Backend developers who know one framework and want to recognise the same pipeline idea in the others, and explain the differences in an interview.
You will be able to
- Describe how a request passes through layers in ASP.NET Core, Express and Django.
- Explain what happens in each framework when a layer answers early or forgets to pass the request on.
- Say where each framework turns an exception into a response.
- Explain why the order of layers is part of a design, with an example of getting it wrong.
- Test a layer by calling it directly, without starting a server.
The key idea: The names differ, but the idea is the same everywhere: each layer does some work, hands the request on, and gets another turn when the response comes back. The real differences between frameworks show up when a layer fails to hand on, throws, or waits.
In this chapter
- One idea in three disguises
- The same two layers, three ways
- Short-circuiting: answering without reaching the endpoint
- Forgetting to hand on: three different failures
- Error handling, three ways
- Async: the cost of getting it wrong
- Order is part of the design
- Layers for everyone, and layers for one route
- Testing a middleware without a server
- What belongs in a layer
- Same shape, different names
- A checklist across chapters 4 and 8
- Mistakes that recur
Locked: needs a plan
You can read chapter 1 free. Chapter 8 is the next one.
What you can do now, free: re-read chapter 1 and try its problems.
What a plan gives you: all chapters of the track you pick and their checks. Professional, one role is ₹329 a month or ₹2,299 a year. It renews until you cancel, and you can cancel any time. Paid plans open at launch.
Why is this locked?
Chapter 1 of every track is free, so you can see how the track reads. The rest of a track and its checks come with a plan, or open as you pass each chapter's check.
The price is for one period, a month or a year. A plan renews until you cancel.