Skip to content

Blazor server InputFile not properly handling exceptions #38824

Open
@Davey-Rodriguez

Description

@Davey-Rodriguez

Describe the bug

When using the <InputFile> 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 <InputFile>? This causes things to seemingly fail silently especially in async methods .

To Reproduce

<InputFile OnChange="@LoadFiles" />
<button @onclick="() => LoadFiles(null)">Blow up</button>

@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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: DesignThis issue requires design work before implementating.Pillar: Technical Debtarea-blazorIncludes: Blazor, Razor Componentsbreaking-changeThis issue / pr will introduce a breaking change, when resolved / merged.bugThis issue describes a behavior which is not expected - a bug.feature-blazor-builtin-componentsFeatures related to the built in components we ship or could ship in the future

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions