Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When attempting to debug a Blazor WebAssembly standalone app in a recent version of a Chromium browser (Chrome or Edge), an unhandled exception is thrown: System.UriFormatException: Invalid URI: Invalid port specified.
This occurs immediately when switching to the "debug in browser" mode, even with the default Blazor WebAssembly template, on a completely clean system.
Update
After further testing, the issue appears to be related to recent versions of Chromium-based browsers.
Debugging works correctly using older versions of Chrome (e.g., version 128 or earlier), but fails with the latest stable version. This suggests the issue may stem from changes in the DevTools protocol or URI handling behavior introduced in Chromium.
This regression prevents proper debugging of Blazor WebAssembly apps in all .NET SDK versions tested (6, 8, and 9).
Expected Behavior
Debugging should start normally without throwing a UriFormatException.
Steps To Reproduce
- Create a clean VM with Windows Server 2022
- Install the latest .NET SDK 9 (reproducible with earlier 8.x versions too)
- Run:
dotnet new blazorwasm -o BlazorWebAssemblyApp
cd BlazorWebAssemblyApp
dotnet run
- Start the browser in debug mode: msedge --remote-debugging-port=9222
- Open the app in the browser and attempt to start debugging with SHIFT+ALT+D
The same behavior occurs across different machines and environments.
Exceptions (if any)
Exception: System.UriFormatException
Stack Trace:
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.UriFormatException: Invalid URI: Invalid port specified.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString)
at Microsoft.AspNetCore.Components.WebAssembly.Server.TargetPickerUi.GetDevToolsUrlWithProxy(HttpRequest request, BrowserTab tabToDebug)
at Microsoft.AspNetCore.Components.WebAssembly.Server.TargetPickerUi.Display(HttpContext context)
at Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.<>c.<b__0_1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.InvokeCore(HttpContext context, PathString matchedPath, PathString remainingPath)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
.NET Version
9.x.x, 8.x.x., 6.x.x
Anything else?
Additional Diagnostics
The output from http://localhost:9222/json is valid (contains a valid webSocketDebuggerUrl)
The UriFormatException seems to occur in the debugger infrastructure when trying to parse the WebSocket URL or during the connection phase.
Environment
OS: Windows Server 2022 (clean install, fully updated)
.NET SDK: 9.x.x (also tried 8.x.x and 6.x.x)
Browsers: Chrome 135.0.7049.96, Edge 135.0.3179.73
Project type: Blazor WebAssembly standalone
Notes
This issue seems to be systemic and not project-specific. It is reproducible even with a minimal blazorwasm template. It may be related to a regression in the .NET SDK or debug proxy tools.
Please advise if there's a patch, fix, or workaround to restore normal debugging support.