What is a Circuit in Blazor Server and how is its lifetime managed?
Last updated
A circuit is a Blazor Server user's session: the
SignalRconnection plus the in-memory component tree, state, andScopedservices.It is created when the connection opens and retained for a configurable window after a disconnect so it can resume. After that timeout it is disposed and all state is lost.
Circuits cost server memory per user (affecting scale). Use
CircuitHandlerto react to connection lifecycle events.
- https://learn.microsoft.com/en-us/answers/questions/1279324/what-does-scoped-lifetime-for-a-service-mean-in-bl
- https://medium.com/@dgallivan23/blazor-server-can-feel-almost-magical-3d339ed7907f
- https://learn.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-10.0
- https://learn.microsoft.com/en-us/aspnet/core/blazor/state-management/server?view=aspnetcore-10.0
- https://www.telerik.com/blogs/blazor-basics-leveraging-circuithandler-blazor-server-connection-level-monitoring
- https://blazor-university.com/dependency-injection/dependency-lifetimes-and-scopes/scoped-dependencies/