Blazor: There was an unhandled exception on the current circuit

When trying out the new Blazor project type in Visual Studio 2019 I encountered this error:

There was an unhandled exception on the current circuit, so this circuit will be terminated. For more details turn on detailed exceptions in ‘CircuitOptions.DetailedErrors’.

There was an unhandled exception on the current circuit, so this circuit will be terminated. For more details turn on detailed exceptions in 'CircuitOptions.DetailedErrors'.
There was an unhandled exception on the current circuit, so this circuit will be terminated. For more details turn on detailed exceptions in ‘CircuitOptions.DetailedErrors’.

It turns out I was simply missing a service reference in the Startup.cs file.

The page I was trying to navigate to was one I had created by copying and modifying the “Weather Forecast” page that comes with the default Blazor template you get out of the box when you create a new Blazor project.
In this page a service and model from the ‘Data’ folder are used to simulate retrieving data from a source and delivering it to the page:

Solution with new page added by copying and modifying the default ‘WeatherForecast’ page that is included as an example within a new Blazor project template.

Adding the missing reference to the startup file fixed the issue. No more “unhandled exception on the current circuit” error when navigating to the new page 🙂

Added missing service reference to the Blazor page service in the Startup.cs file
Added missing service reference to the Blazor page service in the Startup.cs file

Leave a Reply

Your email address will not be published.