0
Answer

What’s the practical difference between Handler and Service in .NET?

I’m working on a .NET Core application using the CQRS pattern with MediatR, and I’m confused about the real difference between a Handler and a Service.

Both seem to contain business logic, but the usage pattern looks different:

  • Services are reusable classes used across multiple areas.

  • Handlers execute one specific command/query (ex: CreateUserHandler, UpdateOrderHandler).

My doubts:

  1. Should business logic be placed inside the Handler directly, or inside a Service and called by the Handler?

  2. When is it appropriate to create a Service instead of putting everything inside a Handler?

  3. Is it considered bad practice if my handlers become big?

  4. Do services still make sense if I’m using strict CQRS with MediatR?

I want to keep my architecture clean and follow best practices, so what’s the recommended approach?