runtime: "Failed to load response data" after non-200 http request with Blazor HttpClient in Chromium based browsers

Describe the bug

Http response data not available if request ends with non-200 http status code (tested with 500).
“Failed to load response data” message in Network tab in Chrome developer tools and net::ERR_ABORTED 500 error in console.

Same request executed by hand shows response data in Response tab in Network tab.

fetch('https://localhost:5001/WeatherForecast')

After some investigation (by debugging) i found that error may be due to passing AbortController as signal parameter to fetch() method. But i can’t found source code for this.

Reproducible in Chromium based browsers, tested in:

  • Chrome 85.0.4183.121
  • Microsoft Edge 86.0.622.38

Works fine in Firefox 80.0.1 (64-bit)

To Reproduce

repro: https://github.com/amityagov/blazor-http-500-aborted

WeatherForecastController::Get modified so it will throw exception after invocation.

Exceptions (if any)

Request info in browser console: GET https://localhost:5001/WeatherForecast net::ERR_ABORTED 500

Further technical details

dotnet --info .NET SDK (reflecting any global.json): Version: 5.0.100-rc.1.20452.10 Commit: 473d1b592e

Runtime Environment: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\

Host (useful for support): Version: 5.0.0-rc.1.20451.14 Commit: 38017c3935

.NET SDKs installed: 3.1.402 [C:\Program Files\dotnet\sdk] 5.0.100-preview.8.20417.9 [C:\Program Files\dotnet\sdk] 5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: old runtimes skipped Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0-preview.7.20364.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0-preview.8.20407.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.0-preview.8.20411.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.0-rc.1.20452.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (19 by maintainers)

Most upvoted comments

@kjpou1 Hello, No, no redirects intended. Just data loading with ajax.

I did not find any information about Chrome, this is just my conclusion based on a comparison of the browser behavior of Firefox and Chrome. But in the following article there is an indirect confirmation of the situation.

https://groups.google.com/a/chromium.org/g/chromium-dev/c/Fal1ZJnTgGQ/m/UDdxbrf_Rv4J

The error code net::ERR_ABORTED is intended to only be generated when a user action causes a load to be interrupted.

Maybe load interuption caused by exception thrown after calling response.EnsureSuccessStatusCode()

This is the error I am getting with the repro

This is call stack from console. I do not know how, but it is different from the one presented by you.

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Response status code does not indicate success: 500 (Internal Server Error).
System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at System.Net.Http.Json.HttpClientJsonExtensions.<GetFromJsonAsyncCore>d__9`1[[blazor_http_500_aborted.Shared.WeatherForecast[], blazor-http-500-aborted.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at blazor_http_500_aborted.Client.Pages.FetchData.OnInitializedAsync() in D:\tests\blazor-http-500-aborted\Client\Pages\FetchData.razor:line 43
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)