In my .NET 8 Blazor solution, I created a project for the application's services, such as API calls.
In the Program.cs in the server project, I added the dependency like this:
builder.Services.AddScoped<ClientService>();Then, in the client project, on the page, I use the Inject to get an instance of the service like
@rendermode InteractiveAuto@code { [Inject] public ClientService? _clientService { get; set; }}The first time the page is loaded, it works fine. However, if I refresh the page, for example, with Ctrl+F5, the _clientService is null.
How can I avoid this error?
