dotnet / dotnet/AspNetCore.Docs
UUF: Background tasks with hosted services: service reg example
- Dominant language
- C#
- Stars
- 13.1k
- Forks
- 24.6k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 109
Description
### Description
User feedback transferred from UUF system:
"I don't understand how I'm supposed to start doing this with a project targeting the Microsoft.NET.Sdk.Web SDK. It says I can use dependency injection which is great, but there's no documentation on how I should DI the service or build it in Program.cs"
**What the article shows:**
It demonstrates how to implement background services in Worker SDK projects (Microsoft.NET.Sdk.Worker)
It shows the implementation classes and service registration for Worker projects
**What the article is missing:**
It doesn't show how to register these same background services in Web SDK projects (Microsoft.NET.Sdk.Web)
While it mentions that Web SDK projects can use hosted services, it doesn't provide a concrete example of the Program.cs structure for a web application. Consider adding one.
### Page URL
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-9.0&tabs=visual-studio
### Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/host/hosted-services.md
### Document ID
b2dece1f-15b8-03af-6d52-7cc070432b4b
### Platform Id
397125bc-12c3-8f36-bb0b-efb01a1e9f43
### Article author
@tdykstra
### Metadata
* ID: c3460b0d-9c60-3a06-ac63-18cf990e53c3
* PlatformId: 397125bc-12c3-8f36-bb0b-efb01a1e9f43
* Service: **aspnet-core**
* Sub-service: **fundamentals**
[Related Issues](https://github.com/dotnet/AspNetCore.Docs/issues?q=is%3Aissue+is%3Aopen+b2dece1f-15b8-03af-6d52-7cc070432b4b)
Contributor guide
Assessment
This issue has not been assessed yet.