-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor WebAssembly browser debugging fails with UriFormatException using recent Chrome versions #61559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We're seeing this behavior as well, at first thought it was related to recently added authentication, but even with authentication disabled, the problem still occurs. |
Same for me. Does anyone have a link to older versions of chrome? |
Same for us! This is a huge problems for developers who can't debug in other ways.. |
During debugging of the Microsoft.AspNetCore.Components.WebAssembly.Server library, I set a breakpoint on line 370 and intercept the necessary values and, using a small script, generate the necessary working link. |
I've prepared a fix for the debug middleware and I can create a PR if possible but I think that I need to have the "ok" from aspnet team for that.. |
It's strange that this didn't get labeled as untriaged by the bot. @thaystg do you know what's going on here? @lewing this is patch worthy if debugging is broken an we need to fix something. @Dona278 thanks for volunteering to create a PR with a fix. I'm not super familiar with what the change is to fix this, so it will greatly help us if you can clarify a couple of questions:
If this affects older/released versions we will likely need to backport the fix. |
Looking at the description it looks like the format of the http://localhost:9222/json was changed. I can investigate it. |
Thanks @javiercn! The "new" result: [
{
"description": "",
"devtoolsFrontendUrl": "https://chrome-devtools-frontend.appspot.com/serve_rev/@031848bc6ad02b97854f3d6154d3aefd0434756a/inspector.html?ws=localhost:9222/devtools/page/719FE9D3B43570193235446E0AB36859",
"id": "719FE9D3B43570193235446E0AB36859",
"title": "localhost:9222/json",
"type": "page",
"url": "http://localhost:9222/json",
"webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/719FE9D3B43570193235446E0AB36859"
}
] The property Proposal: If that url was normalized by "removing domain" and then "ensure that start with devtools/", then will result in the correct url. |
@Dona278 go ahead and open the PR if you want! |
Already fixed here |
Appreciate your work! |
Is there an existing issue for this?
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
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.
The text was updated successfully, but these errors were encountered: