Live Chat Icon For mobile
Live Chat Icon

How do I resolve the error “There was an unhandled exception on the current circuit, so this circuit will be terminated. For more information, turn on detailed exceptions in ‘CircuitOptions.DetailedErrors’.”?

Platform: Blazor| Category: Error handling

To resolve and get more information about the error, enable the ‘CircuitOptions.DetailedErrors’ configuration in the ConfigureServices method in Startup.cs file.

[Startup.cs]

public void ConfigureServices(IServiceCollection services)
{
   // . . .
   services.AddServerSideBlazor().AddCircuitOptions(option => { option.DetailedErrors = true; });
}

For the debug and development environment, initialize the IWebHostEnvironment and provide the web hosting environment information to the Startup constructor. Finally, add the AddCircuitOption configuration to the ConfigureServices method in the Startup.cs file.

[Startup.cs]

public class Startup
{
   // . . .
   public IWebHostEnvironment _env { get; }
   public Startup(IConfiguration configuration, IWebHostEnvironment env)
   {
       Configuration = configuration;
       _env = env;
   }

   public void ConfigureServices(IServiceCollection services)
   {
       // . . .
       services.AddServerSideBlazor().AddCircuitOptions(option =>
       {
           if (_env.IsDevelopment()) //Only add details when debugging.
           {
               option.DetailedErrors = true;
           }
       });
   }
}

Share with

Share on twitter
Share on facebook
Share on linkedin