← Foundations path
.NETFoundations 19 / 37

Service

“What is a service in ASP.NET Core?”

An object whose job is to do work for other code, handed to the code that needs it.

See it

GET /api/loans/{id}LoansControllerLoanServiceEMI 10,501Loandata, not a serviceWritten by your teamInMemoryLoanRepositoryIndiaRulesComes with .NETTimeProviderContainer
1 / 10A asks for one loan. receives it, but does no loan work itself.

In plain words

A service is an object whose job is to do work for other code: find a loan, round an , tell the time. The controller does not do that work itself. It asks a service. A is not a service; it is data the services pass around. Some services are written by your team, others come with .NET. You never build them with : the builds each one and hands it to the class that asks for it.

Say it in the interview

In the lending API

Five files from the lending API, before the database is added. Press Next line to walk through them.

Lending.sln · where these 5 files sit
  • src/
    • Api/
      • Controllers/Servicing/
    • Application/Servicing/Loans/
    • Infrastructure/Servicing/
Diagram · step 7 comes with .NET. Microsoft wrote it; your code gets it the same way.
GET /api/loans/{id}LoansControllerLoanServiceEMI 10,501Loandata, not a serviceWritten by your teamInMemoryLoanRepositoryIndiaRulesComes with .NETTimeProviderContainer
Program.cs · line 11 · 1 of 6These services are written by Microsoft. One call adds each to the list the builds from.

What they ask next

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

Traps

With AI tools

Infosys (2024) and EPAM Pune (Feb 2026) reports still ask DI in .NET rounds, and reviewing AI-written code is a growing interview task. An AI tool may write new InMemoryLoanRepository() inside a service. It compiles and works, so the catch is yours to explain: the class is now welded to one store and cannot be tested with a fake.

Read more: Microsoft Learn: dependency injection in ASP.NET Core · Microsoft Learn: .NET dependency injection · Microsoft Learn: TimeProvider