Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor client-side debugging

I noticed that all of my C# breakpoints do not get hit as debugging seems like its disabled for client-side Blazor apps.

Is there a way to attach the debugger or enable the debugger somehow?

Thanks

like image 462
AlvinfromDiaspar Avatar asked May 23 '19 02:05

AlvinfromDiaspar


People also ask

Is Blazor a client-side?

Blazor WebAssembly. Blazor WebAssembly (WASM) apps run client-side in the browser on a WebAssembly-based .

Is client-side Blazor production ready?

Yes, Blazor is ready to be used in production, it is a life changer, Blazor is a framework that optimizes development speed, helps considerably reducing code duplication and inconsistencies between front-end and api/backend models, and in turn it helps reducing bugs and development costs, in top of that, since Blazor ...

Is Blazor a spa?

Blazor WebAssembly is a single-page app (SPA) framework for building interactive client-side web apps with . NET. Blazor WebAssembly uses open web standards without plugins or recompiling code into other languages. Blazor WebAssembly works in all modern web browsers, including mobile browsers.


2 Answers

For those who like some pictures, here's a step by step using Visual Studio 16.4 preview (.NET Core 3.1 preview 2) & Chrome version 78.

Start up the app using a debug profile. E.g.

Start debugging

After site loads, and with the cursor focus on the chrome tab press "Shift+Alt+D".

Site loads

Chrome will open a new tab showing "Unable to find debuggable browser tab". Find the first instance of the message "Press Win+R". Copy the full line below which starts "chrome -- remote-debugging-port..."

Remote debugging

Hit "Win+R" and paste in the text you just copied and hit enter. A new Chrome window will open..

For the second time, press "Shift+Alt+D" and you should now see something a bit more promising..

Chrome debugger

From here, set a few breakpoints, E.g.

Set your breakpoints

Go back to the tab running Blazor app, trigger your breakpoint. From here you can press F10 for a single step, and F8 for resume. Inspect locals via the "Scope" window as shown.

Finally, the locals are shown!

like image 200
fuzzy_logic Avatar answered Oct 18 '22 21:10

fuzzy_logic


There is no debugging experience for client-side Blazor in Visual Studio.The only option right now is to use the Chrome debugger.

This is all explained in the official documentation, https://docs.microsoft.com/en-gb/aspnet/core/blazor/debug?view=aspnetcore-3.0

like image 34
Chris Sainty Avatar answered Oct 18 '22 21:10

Chris Sainty