Unable to hit breakpoints in Blazor Web Assembly Hosted
See original GitHub issueHi,
My colleague and I have spent a couple of days trying to get our .NET 5.0 Hosted Blazor Web Assembly app to stop on breakpoints we set in the Client i.e. Blazor project.
Breakpoints set in the Server project work as expected, its just the breakpoints for Blazor components that aren’t working.
I have submitted a bug report via the Visual Studio UI so all the detail, screenshots and log files will be attached to that. https://developercommunity.visualstudio.com/t/breakpoints-set-in-blazor-counter-component-not-hi/1376252
I’m assuming at some point once the ticket on the developer community I’ve raised has been triaged and accepted as a genuine bug then it might come through to you guys.
The issue seems to be related to a specific Blazor solution as both myself and my colleague can create a new Blazor Web Assembly Hosted app using the built in Visual Studio template and setting a breakpoint in the Counter component works as expected; as it is hit when clicking the “Click me” button to increment the counter.
Things tried so far that haven’t helped:
- Increased the JSDebugger timeout by running command:
VsRegEdit.exe set "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview" HKCU JSDebugger\Options\Debugging "BlazorTimeoutInMilliseconds" dword 60000
-
Tried deleting my .vs folder in case something in there got screwed up.
-
Tried comparing the
launchSettings.jsonfiles from theClientandServerprojects between the working and non-working solutions and can’t see any differences except for the generated port numbers. -
Tried using Chrome debugging by selecting
Shift+Alt+Dbut the tab that opens has an exception listed and this is the same of the working solution and the non-working solution.
System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. (localhost:9222)
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|283_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.DefaultConnectAsync(SocketsHttpConnectionContext context, CancellationToken cancellationToken)
at System.Net.Http.ConnectHelper.ConnectAsync(Func`3 callback, DnsEndPoint endPoint, HttpRequestMessage requestMessage, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(Func`3 callback, DnsEndPoint endPoint, HttpRequestMessage requestMessage, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Components.WebAssembly.Server.TargetPickerUi.GetOpenedBrowserTabs()
at Microsoft.AspNetCore.Components.WebAssembly.Server.TargetPickerUi.Display(HttpContext context)
- Did a file compare of the contents of the
%TEMP%\visualstudio-js-debugger.txtand compared when the application was running idle in a debug session (VSF5) and when I clicked a breakpoint that failed to be bound on theCountercomponent and the difference between the two was:
{"tag":"dap.receive","timestamp":1616174312418,"metadata":{"connectionId":0,"message":{"type":"request","command":"setBreakpoints","arguments":{"source":{"path":"c:\\Users\\Ady\\BitBucket\\MB5\\Client\\Pages\\Counter.razor","sources":[],"checksums":[]},"breakpoints":[{"line":14,"column":9}],"lines":[14]},"seq":5}},"level":0}
{"tag":"dap.send","timestamp":1616174312418,"metadata":{"connectionId":0,"message":{"seq":20,"type":"response","request_seq":5,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"id":1,"verified":false,"message":"Unbound breakpoint"}]}}},"level":0}
{"tag":"dap.receive","timestamp":1616174312440,"metadata":{"connectionId":1,"message":{"type":"request","command":"setBreakpoints","arguments":{"source":{"path":"c:\\Users\\Ady\\BitBucket\\MB5\\Client\\Pages\\Counter.razor","sources":[],"checksums":[]},"breakpoints":[{"line":14,"column":9}],"lines":[14]},"seq":5}},"level":0}
{"tag":"cdp.send","timestamp":1616174312441,"metadata":{"connectionId":0,"message":{"id":1022,"method":"Debugger.setInstrumentationBreakpoint","params":{"instrumentation":"beforeScriptWithSourceMapExecution"},"sessionId":"CA79CB66D7B7DC4655EEEACFDAE9978C"}},"level":0}
{"tag":"cdp.receive","timestamp":1616174312443,"metadata":{"connectionId":0,"message":{"id":1022,"sessionId":"CA79CB66D7B7DC4655EEEACFDAE9978C","result":{"breakpointId":"8:beforeScriptWithSourceMapExecution"}}},"level":0}
{"tag":"perf.function","timestamp":1616174312479,"message":"","metadata":{"method":"BreakpointsPredictor.createInitialMapping","duration":36},"level":0}
{"tag":"cdp.send","timestamp":1616174312481,"metadata":{"connectionId":0,"message":{"id":1023,"method":"Debugger.setBreakpointByUrl","params":{"urlRegex":"[fF][iI][lL][eE]:\\/\\/\\/[cC]:\\/[uU][sS][eE][rR][sS]\\/[aA][dD][yY]\\/[bB][iI][tT][bB][uU][cC][kK][eE][tT]\\/[mM][bB]5\\/[cC][lL][iI][eE][nN][tT]\\/[pP][aA][gG][eE][sS]\\/[cC][oO][uU][nN][tT][eE][rR]\\.[rR][aA][zZ][oO][rR]|[cC]:\\\\[uU][sS][eE][rR][sS]\\\\[aA][dD][yY]\\\\[bB][iI][tT][bB][uU][cC][kK][eE][tT]\\\\[mM][bB]5\\\\[cC][lL][iI][eE][nN][tT]\\\\[pP][aA][gG][eE][sS]\\\\[cC][oO][uU][nN][tT][eE][rR]\\.[rR][aA][zZ][oO][rR]","lineNumber":0,"columnNumber":0},"sessionId":"CA79CB66D7B7DC4655EEEACFDAE9978C"}},"level":0}
{"tag":"cdp.send","timestamp":1616174312482,"metadata":{"connectionId":0,"message":{"id":1024,"method":"Debugger.setBreakpointByUrl","params":{"urlRegex":"[fF][iI][lL][eE]:\\/\\/\\/[cC]:\\/[uU][sS][eE][rR][sS]\\/[aA][dD][yY]\\/[bB][iI][tT][bB][uU][cC][kK][eE][tT]\\/[mM][bB]5\\/[cC][lL][iI][eE][nN][tT]\\/[pP][aA][gG][eE][sS]\\/[cC][oO][uU][nN][tT][eE][rR]\\.[rR][aA][zZ][oO][rR]|[cC]:\\\\[uU][sS][eE][rR][sS]\\\\[aA][dD][yY]\\\\[bB][iI][tT][bB][uU][cC][kK][eE][tT]\\\\[mM][bB]5\\\\[cC][lL][iI][eE][nN][tT]\\\\[pP][aA][gG][eE][sS]\\\\[cC][oO][uU][nN][tT][eE][rR]\\.[rR][aA][zZ][oO][rR]","lineNumber":13,"columnNumber":8},"sessionId":"CA79CB66D7B7DC4655EEEACFDAE9978C"}},"level":0}
{"tag":"cdp.receive","timestamp":1616174312558,"metadata":{"connectionId":0,"message":{"id":1024,"sessionId":"CA79CB66D7B7DC4655EEEACFDAE9978C","result":{"breakpointId":"2:13:8:[fF][iI][lL][eE]:\\/\\/\\/[cC]:\\/[uU][sS][eE][rR][sS]\\/[aA][dD][yY]\\/[bB][iI][tT][bB][uU][cC][kK][eE][tT]\\/[mM][bB]5\\/[cC][lL][iI][eE][nN][tT]\\/[pP][aA][gG][eE][sS]\\/[cC][oO][uU][nN][tT][eE][rR]\\.[rR][aA][zZ][oO][rR]|[cC]:\\\\[uU][sS][eE][rR][sS]\\\\[aA][dD][yY]\\\\[bB][iI][tT][bB][uU][cC][kK][eE][tT]\\\\[mM][bB]5\\\\[cC][lL][iI][eE][nN][tT]\\\\[pP][aA][gG][eE][sS]\\\\[cC][oO][uU][nN][tT][eE][rR]\\.[rR][aA][zZ][oO][rR]","locations":[]}}},"level":0}
{"tag":"dap.send","timestamp":1616174312558,"metadata":{"connectionId":1,"message":{"seq":6409,"type":"response","request_seq":5,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"id":1,"verified":false,"message":"Unbound breakpoint"}]}}},"level":0}
{"tag":"cdp.receive","timestamp":1616174312610,"metadata":{"connectionId":0,"message":{"id":1023,"sessionId":"CA79CB66D7B7DC4655EEEACFDAE9978C","result":{"breakpointId":"2:0:0:[fF][iI][lL][eE]:\\/\\/\\/[cC]:\\/[uU][sS][eE][rR][sS]\\/[aA][dD][yY]\\/[bB][iI][tT][bB][uU][cC][kK][eE][tT]\\/[mM][bB]5\\/[cC][lL][iI][eE][nN][tT]\\/[pP][aA][gG][eE][sS]\\/[cC][oO][uU][nN][tT][eE][rR]\\.[rR][aA][zZ][oO][rR]|[cC]:\\\\[uU][sS][eE][rR][sS]\\\\[aA][dD][yY]\\\\[bB][iI][tT][bB][uU][cC][kK][eE][tT]\\\\[mM][bB]5\\\\[cC][lL][iI][eE][nN][tT]\\\\[pP][aA][gG][eE][sS]\\\\[cC][oO][uU][nN][tT][eE][rR]\\.[rR][aA][zZ][oO][rR]","locations":[]}}},"level":0}
{"tag":"dap.send","timestamp":1616174317424,"metadata":{"connectionId":0,"message":{"seq":21,"type":"event","event":"output","body":{"category":"telemetry","output":"js-debug/dap/operation","data":{"browser":"Chrome/89.0.4389.90","errors":[],"setBreakpoints":{"operation":"setBreakpoints","totalTime":1.3,"max":1.3,"avg":1.3,"stddev":null,"count":1,"failed":0},"!setBreakpoints.errors":[],"setBreakpoints.errors":[]}}}},"level":0}
{"tag":"dap.send","timestamp":1616174317561,"metadata":{"connectionId":1,"message":{"seq":6410,"type":"event","event":"output","body":{"category":"telemetry","output":"js-debug/dap/operation","data":{"errors":[],"setBreakpoints":{"operation":"setBreakpoints","totalTime":118.6,"max":118.6,"avg":118.6,"stddev":null,"count":1,"failed":0},"!setBreakpoints.errors":[],"setBreakpoints.errors":[]}}}},"level":0}
{"tag":"dap.receive","timestamp":1616174322183,"metadata":{"connectionId":0,"message":{"type":"request","command":"disconnect","arguments":{"terminateDebuggee":true},"seq":6}},"level":0}
{"tag":"cdp.send","timestamp":1616174322185,"metadata":{"connectionId":0,"message":{"id":1025,"method":"Target.closeTarget","params":{"targetId":"5A102052ECEABD6EE832540F9E45F568"},"sessionId":"D265389048E5830AE5C635F7320E811A"}},"level":0}
{"tag":"dap.receive","timestamp":1616174322186,"metadata":{"connectionId":1,"message":{"type":"request","command":"disconnect","arguments":{"terminateDebuggee":false},"seq":6}},"level":0}
{"tag":"dap.send","timestamp":1616174322186,"metadata":{"connectionId":1,"message":{"seq":6411,"type":"event","event":"output","body":{"category":"telemetry","output":"js-debug/breakpointStats","data":{"set":1,"verified":0,"hit":0}}}},"level":0}
{"tag":"cdp.send","timestamp":1616174322187,"metadata":{"connectionId":0,"message":{"id":1026,"method":"Target.detachFromTarget","params":{"sessionId":"CA79CB66D7B7DC4655EEEACFDAE9978C"},"sessionId":"D265389048E5830AE5C635F7320E811A"}},"level":0}
{"tag":"dap.send","timestamp":1616174322188,"metadata":{"connectionId":1,"message":{"seq":6412,"type":"event","event":"thread","body":{"reason":"exited","threadId":0}}},"level":0}
{"tag":"dap.send","timestamp":1616174322188,"metadata":{"connectionId":1,"message":{"seq":6413,"type":"response","request_seq":6,"command":"disconnect","success":true,"body":{}}},"level":0}
{"tag":"dap.send","timestamp":1616174322194,"metadata":{"connectionId":1,"message":{"seq":6414,"type":"event","event":"terminated","body":{}}},"level":0}
{"tag":"cdp.receive","timestamp":1616174322196,"metadata":{"connectionId":0,"message":{"id":1025,"sessionId":"D265389048E5830AE5C635F7320E811A","result":{"success":true}}},"level":0}
{"tag":"dap.send","timestamp":1616174322197,"metadata":{"connectionId":0,"message":{"seq":22,"type":"event","event":"terminated","body":{}}},"level":0}
{"tag":"dap.send","timestamp":1616174322198,"metadata":{"connectionId":0,"message":{"seq":23,"type":"response","request_seq":6,"command":"disconnect","success":true,"body":{}}},"level":0}
{"tag":"dap.send","timestamp":1616174327201,"message":"Not sending message because the connection has ended","metadata":{"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"js-debug/dap/operation","data":{"browser":"Chrome/89.0.4389.90","errors":[],"disconnect":{"operation":"disconnect","totalTime":14.8,"max":14.8,"avg":14.8,"stddev":null,"count":1,"failed":0},"!disconnect.errors":[],"disconnect.errors":[]}}},"level":2}
The problem I’ve got is that I’m not able to give you repro steps as it seems specific to this one solution and the solution itself isn’t one I can share publicly.
Do you have any pointers to what else I can check/do?
Many thanks.
Further technical details
.NET SDK (reflecting any global.json):
Version: 5.0.201
Commit: a09bd5c86c
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.201\
Host (useful for support):
Version: 5.0.4
Commit: f27d337295
.NET SDKs installed:
3.1.300-preview-015048 [C:\Program Files\dotnet\sdk]
3.1.407 [C:\Program Files\dotnet\sdk]
5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]
5.0.104 [C:\Program Files\dotnet\sdk]
5.0.200-preview.20614.14 [C:\Program Files\dotnet\sdk]
5.0.200-preview.21077.7 [C:\Program Files\dotnet\sdk]
5.0.201 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
- ASP.NET Core SDK 5.0.201 (v5.0.4)
- Visual Studio Profession 2019 Preview - Version 16.10.0 Preview 1.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)

Top Related StackOverflow Question
Hi,
I have an update for you on this issue.
I have spent the day today copying code/files across from the failing solution to a new Blazor vanilla VS template solution where the breakpoints work.
I put a breakpoint on the
Counterpage where thecurrentCountvariable is being incrementedcurrentCount++;and tested at every step that I could still hit the breakpoint until I got to the point where the breakpoint stopped working.This process allowed me to narrow it down to a single Blazor razor component page and then down to a single line of code within that page.
The line of code that was causing the failing breakpoints was an
@attributedirective to add a customAuthoriseAttributeattribute calledAuthoriseByUserRolesAttributewhich I had created to allow me to pass inEnumvalues rather than hardcoded strings for theRolesproperty.So rather than having to use hardcoded strings like this:
@attribute [Authorize(Roles = "AdminUser")]The custom attribute allows me to do this:
@attribute [AuthoriseByUserRoles(UserRole.AdminUser)]The custom
AuthoriseAttributewas implemented like this:The
Enumwas defined like this:The strange thing is that this page was NOT causing any errors in the VS output window or the Chrome console (as far as I am aware) and compiled fine and ran when pressing
F5.Whatever the issue is on this one page that uses the custom attribute seems to affect other pages, for example this would stop breakpoints from working on an unrelated
Counterpage.I went to create a simple repro of the issue using as the base a new vanilla Blazor WebAssembly Hosted app with HTTPS and Individual Auth.
I added the custom attribute
AuthoriseByUserRolesAttributeandUserRoleenum to theClientproject as it was easiest to added them there for the repro.When I ran the repro project I expected the breakpoints to fail, but they worked which confused me.
Repro with customisations added to
Clientproject is here: https://github.com/adrianwright109/BPsHittingWithCustomAuthoriseAttributeInClientProjectI then realised in my actual app that these classes are in a
Commonclass library not directly in theClientproject so I created a second repro this time mimicking the same project structure as the real app. With the customisations added toCommonproject the breakpoints fail to be hit.Repro with customisations added to
Commonproject is here: https://github.com/adrianwright109/BPsNotHittingWithCustomAuthoriseAttributeInCommonProjectN.B. The custom attribute
AuthoriseByUserRolesAttributehas been added to theFetchDatapage.@adrianwright109 Perfect! Great to have validation that the fix put in indeed works. Thanks for taking the time to test everything out.