Making things break
Edsger W. Dijkstra once said,
“If debugging is the process of removing software bugs, then programming must be the process of putting them in.”
This is definitely true in this section because we will add a page that will throw an exception:
- In the
SharedComponents
project, in thePages
folder, create a new Razor component calledThrowException.razor
. - Replace the contents of the file with the following code block:
@page "/ThrowException" @rendermode @(new InteractiveServerRenderMode(prerender: false)) <button @onclick="@(()=> {throw new Exception("Something is broken"); })">Throw an exception</button>
This page shows a button, and when you press it, it throws an exception.
Great! We have our application’s Ivan Drago (he wants to break us, but we might just beat him with some fancy debugging).
The next step is to take a look at Blazor Server...