# Hosted Service

Background code that starts and stops with the app.

## What is **Hosted Service**?

A **hosted service** (`IHostedService`) is background code that starts and stops with the app, such as a queue listener or a scheduled cleanup.

```csharp
builder.Services.AddHostedService<NightlyCleanup>();
```

Level: Freelancer · [More ASP.NET Core terms at this level](https://www.ask-codey.com/glossary?category=aspnet-core&level=4)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/hosted-service
