Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions aspnetcore/fundamentals/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: tdykstra
description: Learn how to use the Configuration API to configure app settings in an ASP.NET Core app.
monikerRange: '>= aspnetcore-3.1'
ms.author: tdykstra
ms.date: 04/28/2026
ms.date: 09/18/2026
uid: fundamentals/configuration/index
---
# Configuration in ASP.NET Core
Expand Down Expand Up @@ -1625,9 +1625,9 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
});
```

::: moniker-end
For an example of accessing configuration using startup convenience methods, see [App startup: Convenience methods](xref:fundamentals/startup#configure-services-without-a-startup-class).

For an example of accessing configuration using startup convenience methods, see [App startup: Convenience methods](xref:fundamentals/startup#convenience-methods).
::: moniker-end

## Add configuration from an external assembly

Expand Down
21 changes: 20 additions & 1 deletion aspnetcore/fundamentals/host/hosted-services.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Background tasks with hosted services in ASP.NET Core
ai-usage: ai-assisted
author: tdykstra
description: Learn how to implement background tasks with hosted services in ASP.NET Core.
monikerRange: '>= aspnetcore-3.1'
ms.author: tdykstra
ms.date: 05/28/2025
ms.date: 09/18/2026
Comment thread
guardrex marked this conversation as resolved.
uid: fundamentals/host/hosted-services
---
# Background tasks with hosted services in ASP.NET Core
Expand Down Expand Up @@ -55,6 +56,15 @@ The <xref:Microsoft.Extensions.Hosting.IHostedService> interface defines two met

`StartAsync` should be limited to short running tasks because hosted services are run sequentially, and no further services are started until `StartAsync` runs to completion.

Hosted service instances start in the order that they're registered in the dependency injection container unless the app opts into concurrent startup by setting <xref:Microsoft.Extensions.Hosting.HostOptions.ServicesStartConcurrently> to `true`:

```csharp
builder.Services.Configure<HostOptions>(options =>
{
options.ServicesStartConcurrently = true;
});
```

### `StopAsync`

* [StopAsync(CancellationToken)](xref:Microsoft.Extensions.Hosting.IHostedService.StopAsync%2A) is triggered when the host is performing a graceful shutdown. `StopAsync` contains the logic to end the background task. Implement <xref:System.IDisposable> and [finalizers (destructors)](/dotnet/csharp/programming-guide/classes-and-structs/destructors) to dispose of any unmanaged resources.
Expand All @@ -75,6 +85,15 @@ To extend the default 30 second shutdown timeout, set:

The hosted service is activated once at app startup and gracefully shut down at app shutdown. If an error is thrown during background task execution, `Dispose` should be called even if `StopAsync` isn't called.

Hosted service instances stop in the reverse order that they're registered in the dependency injection container unless the app opts into concurrent shutdown behavior by setting <xref:Microsoft.Extensions.Hosting.HostOptions.ServicesStopConcurrently> to `true`:

```csharp
builder.Services.Configure<HostOptions>(options =>
{
options.ServicesStopConcurrently = true;
});
```

## BackgroundService base class

<xref:Microsoft.Extensions.Hosting.BackgroundService> is a base class for implementing a long running <xref:Microsoft.Extensions.Hosting.IHostedService>.
Expand Down
12 changes: 10 additions & 2 deletions aspnetcore/fundamentals/logging/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: tdykstra
description: Learn how to use the ASP.NET Core logging framework provided by the Microsoft.Extensions.Logging NuGet package.
monikerRange: '>= aspnetcore-3.1'
ms.author: tdykstra
ms.date: 01/23/2026
ms.date: 09/18/2026
uid: fundamentals/logging/index
---
# Logging in .NET and ASP.NET Core
Expand Down Expand Up @@ -866,7 +866,15 @@ On Linux, the `Debug` provider log location is distribution-dependent and may be

### `EventSource`

The `EventSource` provider writes to a cross-platform event source with the name `Microsoft-Extensions-Logging`. On Windows, the provider uses [ETW](/windows/win32/etw/event-tracing-portal).
<xref:Microsoft.Extensions.Logging.EventSource.EventSourceLoggerProvider> writes to a cross-platform event source with the name `Microsoft-Extensions-Logging`. On Windows, the provider uses [ETW](/windows/win32/etw/event-tracing-portal).

:::moniker range=">= aspnetcore-7.0"

#### `ServerReady` event to measure startup time

The ASP.NET Core hosting <xref:System.Diagnostics.Tracing.EventSource> emits the <!--keep-->[`ServerReady`](https://source.dot.net/#Microsoft.AspNetCore.Hosting/Internal/HostingEventSource.cs,76) event in <xref:Microsoft.AspNetCore.Hosting?displayProperty=fullName>, which represents the point where the server is ready to respond to requests and can be used to measure startup time.

:::moniker-end

#### `dotnet-trace` tooling

Expand Down
433 changes: 386 additions & 47 deletions aspnetcore/fundamentals/startup.md

Large diffs are not rendered by default.

28 changes: 0 additions & 28 deletions aspnetcore/fundamentals/startup/3.0_samples/Program3.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading