dotnet / dotnet/aspnetcore

Blazor server InputFile not properly handling exceptions

Open
#38,824 9 comments 0 reactions 0 assignees View on GitHub
area-blazor breaking-change bug feature-blazor-builtin-components Needs: Design Pillar: Technical Debt
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Describe the bug
When using the `` and binding the `OnChange="@LoadFiles"` method, if the method throws an exception it will not break the Blazor server circuit or log the error to the server's console. The error will be logged to the browser's console and the app will continue to function as if nothing happened. This behavior seems to differ from everything else I have seen when handling exceptions in Blazor Server.

For example, when I use a normal button and bind the `@onclick="() => LoadFiles(null)` method, an exceptions will be logged to the server's console and the Blazor Server circuit will be broken. Any reason this isn't the same behavior when using ``? This causes things to seemingly fail silently especially in async methods .

### To Reproduce
```

Blow up

@code {
private void LoadFiles(InputFileChangeEventArgs e) {
throw new Exception();
}
}
```

### Further technical details
- ASP.NET Core version: 6
- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version: VS 2022 64-bit Version 17.0.1
- Include the output of `dotnet --info`:

dotnet --info Output

```
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100\

Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa

.NET SDKs installed:
3.0.100 [C:\Program Files\dotnet\sdk]
5.0.200 [C:\Program Files\dotnet\sdk]
6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk]
6.0.100 [C:\Program Files\dotnet\sdk]
```

Contributor guide

Open the contributing guide

Research direction

Start with the InputFile OnChange handling and compare it with the button @onclick path shown in the reproduction. Reproduce the exception in a Blazor Server app and trace whether it reaches the server console and circuit error handling. Done means InputFile exceptions no longer fail silently and match the documented button behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.