dotnet / dotnet/aspnetcore

Blank page and no error when injecting undefined service in InteractiveServer

Open
#52,598 11 comments 0 reactions 0 assignees View on GitHub
area-blazor bug Pillar: Dev Experience Priority:1
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

If you try and inject a service into a blazor server page (with `@rendermode @(new InteractiveServerRenderMode(prerender: false)`), but that service has not been added to the services in Program.cs, all you get is a blank page.

### Expected Behavior

It should throw an exception: There is no registered service of type 'inject.Data.WeatherForecastService'

### Steps To Reproduce

I added the weather forecast service to a plain blazor project, and turned on interactiveserver mode in the weather page.

https://github.com/kevingolding2001/BlazorInjectProblem

### Exceptions (if any)

_No response_

### .NET Version

8.0.100

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.