Blazor FAQ - Debugging

What is the equivalent of console.log in Blazor?

For debugging purposes, we can log or print comments during code execution using Console.WriteLine(“comments”) in Blazor.

Console.WriteLine("Some content logged in Blazor App output window");
Permalink
How do you debug in a client-side Blazor application?

To debug a client-side Blazor app in a browser:

  1. Close the all instances in Chrome.
  2. Run the Blazor app in Chrome (version 70 or later).
  3. Open Win + R and run following command.
"%programfiles(x86)%\Google\Chrome\Application\chrome.exe"   --remote-debugging-port=9222 http://localhost:52902/
  • Now the Blazor app is running.
  • Then hit Shift+Alt+D on Windows or Linux and Shift+Cmd+D on macOS.

Reference link:

https://docs.microsoft.com/en-us/aspnet/core/blazor/debug?view=aspnetcore-3.1

https://www.hanselman.com/blog/CompilingCToWASMWithMonoAndBlazorThenDebuggingNETSourceWithRemoteDebuggingInChromeDevTools.aspx

Permalink
How do I debug a Blazor application client-side?
  1. Run the Blazor application in Debug mode in Chrome 70 and above.
  2. With the focus of the Blazor application in the Chrome browser, run the following
  • Shift+Alt+D on Windows/Linux
  • Shift+Cmd+D on macOS

Refer to Debug Blazor applications for more information.

Permalink
How do you debug a client-side Blazor app in VS Code?

For now, there is no option to debug a client-side Blazor application in VS Code, although the debugging of server-side applications is possible.

Refer to the thread debug Blazor in VS Code for more information.

Permalink