Debugging Blazor WebAssembly
Blazor WebAssembly can of course be debugged as well, but there are some things we need to think about. Since we have our exception page in our shared library, we can go straight into debugging.
But let's start with breakpoints:
- Right-click on MyBlogWebAssembly.Server and select Set as Startup Project.
- Press F5 to debug the project.
Here we can notice the first difference – assuming we still have the breakpoint we set in the Debugging Blazor Server section (in the LoadPosts
method), the breakpoint did not get hit.
Breakpoints won't get hit on the initial page load in Blazor WebAssembly. We need to navigate to another page and back to the index page again for it to hit.
We can't just change the URL, as we could in Blazor Server, simply because that will reload the app again and not trigger the breakpoint because it was an initial page load.
Debugging Blazor WebAssembly is made possible by the following...