Debugging Blazor WebAssembly
Blazor WebAssembly can, of course, be debugged as well. There are a couple of things to keep in mind. Debugging InteractiveWebAssembly
, like we are using in our blog, is going to work just the same as with Blazor Server. Breakpoints and exceptions will work just the same. However, there is an option to run Blazor WebAssembly as a standalone app. And that works a bit differently.
To be able to play around with that, we need to add another project.
- Right-click on the MyBlog solution, select Add, New Project…, and select Blazor WebAssembly Standalone App.
- Change the project name to
BlazorWebAssemblyApp
. - Leave the default values as is and click Create.
- Right-click on our BlazorWebAssemblyApp project and select Set as Startup Project.
- In the Pages folder, open
Counter.razor
and add a breakpoint on thecurrentCount++
row. - Run the project by pressing F5, and lo and behold, the breakpoint is hit.
This...