← Foundations path
.NETFoundations 16 / 37

One HTTP request

“What happens in ASP.NET Core between a request arriving and the response going back?”

The path one web request takes from the browser, through your app, and back.

See it

middlewareBrowserKestrel (web server)routing: match the URL1 UseExceptionHandler2 RequestLoggingMiddlewareendpoint: run the actionLoansController.GetAsyncLoanService.GetAsyncInMemoryLoanRepositoryGET /api/loans/…LoanResponseEMI 10,501
1 / 17The browser sends GET /api/loans/{id}: just text, with a method, a path and some headers.

In plain words

A web request is a short text message. Kestrel, the web server inside your app, receives it. Then it walks down a line of small steps called middleware, in the order Program.cs lists them. Each step can do something on the way in and again on the way out. At the end, your controller runs, asks the service, and the service asks the repository. The answer travels back up the same line, in reverse, and leaves as JSON.

Say it in the interview

In the lending API

Five files from the lending API, in the order a request meets them. Press Next line to walk through them.

Lending.sln · where these 5 files sit
  • src/
    • Api/
      • Middleware/
      • Controllers/Servicing/
      • Errors/
    • Application/Servicing/Loans/
Diagram · step 7Model binding turns the text in the URL into a Guid id. The controller calls the service.
middlewareBrowserKestrel (web server)routing: match the URL1 UseExceptionHandler2 RequestLoggingMiddlewareendpoint: run the actionLoansController.GetAsyncLoanService.GetAsyncInMemoryLoanRepositoryGET /api/loans/…LoanResponseEMI 10,501
Program.cs · line 7 · 1 of 7Turns on controllers: model binding, [ApiController] rules and JSON output.

What they ask next

Interviewers check that you can explain every line. Tap a question to open it.

Traps

With AI tools

Interviews now include reviewing AI-written code. In a generated Program.cs, read the lines as a running order. Any order compiles, but an exception handler placed late misses every error thrown before it.

Read more: Microsoft Learn: ASP.NET Core middleware · Microsoft Learn: write custom middleware · Microsoft Learn: handle errors in web APIs · Microsoft Learn: routing