Debugging a Blazor WebAssembly project

🟥 Not applicable to Blazor Server

Debugging is an essential part of the software development process, and it's no different when it comes to Blazor WebAssembly. In this tutorial, we will be using Visual Studio, a popular development environment for .NET, to debug our Blazor WebAssembly project.

  • Checklist before debugging.
  • Debug with Google Chrome.
  • Debug with Microsoft Edge.

Currently, Mozilla Firefox is unable to debug.


Checklist before debugging

  • Debugging with Mozilla Firefox is not supported. To debug your project, you must use either Google Chrome or Microsoft Edge
  • Using a custom template when creating a new project may prevent you from being able to debug. It's recommended to always use the default template provided by Microsoft and add any third-party extensions afterwards.
  • When you run your project, make sure to check the Launch browser option in order to enable debugging.

open-launch-profile.png

  • You can also add arguments to the browser when launching.

add-arguments.png

add-arguments-2.png

add-arguments-3.png

add-arguments-4.png

For a comprehensive list of arguments for Google Chrome & Microsoft Edge, refer to the following URL: https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_switches.cc.


Debug with Google Chrome

  1. Put a breakpoint in your code.

put-breakpoint.png

  1. Select Google Chrome as your browser.

select-browser-chrome.png

  1. Run your project, and a new window of Google Chrome will appear. Visual Studio will pause at the breakpoint you set in step 1, allowing you to debug your code.

Debug with Microsoft Edge

  1. Put a breakpoint in your code.

put-breakpoint.png

  1. Select Microsoft Edge as your browser.

select-browser-edge.png

  1. Run your project, and a new window of Microsoft Edge will appear. Visual Studio will pause at the breakpoint you set in step 1, allowing you to debug your code.
BLAZOR SCHOOL
Designed and built with care by our dedicated team, with contributions from a supportive community. We strive to provide the best learning experience for our users.
Docs licensed CC-BY-SA-4.0
Copyright © 2021-2024 Blazor School
An unhandled error has occurred. Reload 🗙