-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
A scoped service is instantiated twice in an app with an interactive server render mode and no pre-rendering.
In my project, a razor component sets a value in the scoped service after the scoped service is instantiated the first time, but then it is instantiated again, causing the value to be lost.
Expected Behavior
A scoped service should be instantiated once when pre-rendering is disabled.
Steps To Reproduce
Please see the linked project. With a breakpoint in the TestService
constructor, notice the breakpoint is hit twice due to the injection of the service in _Imports.razor
.
https://github.com/mrlife/BlazorServiceInstantiation
Exceptions (if any)
No response
.NET Version
8.0.101
Anything else?
.NET SDK:
Version: 8.0.101
Commit: 6eceda187b
Workload version: 8.0.100-manifests.69afb982
Runtime Environment:
OS Name: Mac OS X
OS Version: 14.3
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.101/
.NET workloads installed:
Workload version: 8.0.100-manifests.69afb982
[maui]
Installation Source: SDK 8.0.100
Manifest Version: 8.0.3/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.3/WorkloadManifest.json
Install Type: FileBased
Host:
Version: 8.0.1
Architecture: arm64
Commit: bf5e279d92
.NET SDKs installed:
7.0.311 [/usr/local/share/dotnet/sdk]
7.0.312 [/usr/local/share/dotnet/sdk]
8.0.100 [/usr/local/share/dotnet/sdk]
8.0.101 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found