diff --git a/aspnetcore/blazor/fundamentals/dependency-injection.md b/aspnetcore/blazor/fundamentals/dependency-injection.md index ec3977fe68..1d9200c8a4 100644 --- a/aspnetcore/blazor/fundamentals/dependency-injection.md +++ b/aspnetcore/blazor/fundamentals/dependency-injection.md @@ -224,7 +224,7 @@ After services are added to the service collection, inject one or more services ```razor @page "/constructor-injection" - ``` @@ -236,7 +236,10 @@ using Microsoft.AspNetCore.Components; public partial class ConstructorInjection(NavigationManager navigation) { - protected NavigationManager Navigation { get; } = navigation; + private void HandleClick() + { + navigation.NavigateTo("/counter"); + } } ``` @@ -616,7 +619,7 @@ There may be times when a Razor component invokes asynchronous methods that exec For example, instances created using have their own DI service scope. As a result, instances configured on the aren't able to directly inject Blazor services. -Create a class `BlazorServiceAccessor` that defines an [`AsyncLocal`](xref:System.Threading.AsyncLocal`1), which stores the Blazor for the current asynchronous context. A `BlazorServiceAcccessor` instance can be acquired from within a different DI service scope to access Blazor services. +Create a class `BlazorServiceAccessor` that defines an [`AsyncLocal`](xref:System.Threading.AsyncLocal`1), which stores the Blazor for the current asynchronous context. A `BlazorServiceAccessor` instance can be acquired from within a different DI service scope to access Blazor services. `BlazorServiceAccessor.cs`: @@ -769,6 +772,7 @@ services.AddScoped(); * * [`IDisposable` guidance for Transient and shared instances](xref:fundamentals/dependency-injection#idisposable-guidance-for-transient-and-shared-instances) * +* [Primary constructors (C# Guide)](/dotnet/csharp/programming-guide/classes-and-structs/instance-constructors#primary-constructors) :::moniker-end