You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/advanced-scenarios.md
+49-1Lines changed: 49 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,62 @@ description: Learn about advanced scenarios in Blazor, including how to incorpor
5
5
monikerRange: '>= aspnetcore-3.1'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 02/12/2020
8
+
ms.date: 02/18/2020
9
9
no-loc: [Blazor, SignalR]
10
10
uid: blazor/advanced-scenarios
11
11
---
12
12
# ASP.NET Core Blazor advanced scenarios
13
13
14
14
By [Luke Latham](https://github.com/guardrex) and [Daniel Roth](https://github.com/danroth27)
15
15
16
+
## Blazor Server circuit handler
17
+
18
+
Blazor Server allows code to define a *circuit handler*, which allows running code on changes to the state of a user's circuit. A circuit handler is implemented by deriving from `CircuitHandler` and registering the class in the app's service container. The following example of a circuit handler tracks open SignalR connections:
Circuit handlers are registered using DI. Scoped instances are created per instance of a circuit. Using the `TrackingCircuitHandler` in the preceding example, a singleton service is created because the state of all circuits must be tracked:
If a custom circuit handler's methods throw an unhandled exception, the exception is fatal to the Blazor Server circuit. To tolerate exceptions in a handler's code or called methods, wrap the code in one or more [try-catch](/dotnet/csharp/language-reference/keywords/try-catch) statements with error handling and logging.
61
+
62
+
When a circuit ends because a user has disconnected and the framework is cleaning up the circuit state, the framework disposes of the circuit's DI scope. Disposing the scope disposes any circuit-scoped DI services that implement <xref:System.IDisposable?displayProperty=fullName>. If any DI service throws an unhandled exception during disposal, the framework logs the exception.
63
+
16
64
## Manual RenderTreeBuilder logic
17
65
18
66
`Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder` provides methods for manipulating components and elements, including building components manually in C# code.
Copy file name to clipboardExpand all lines: aspnetcore/blazor/handle-errors.md
+1-53Lines changed: 1 addition & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Discover how ASP.NET Core Blazor how Blazor manages unhandled excep
5
5
monikerRange: '>= aspnetcore-3.1'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 02/12/2020
8
+
ms.date: 02/18/2020
9
9
no-loc: [Blazor, SignalR]
10
10
uid: blazor/handle-errors
11
11
---
@@ -95,8 +95,6 @@ Framework and app code may trigger unhandled exceptions in any of the following
95
95
*[Event handlers](#event-handlers)
96
96
*[Component disposal](#component-disposal)
97
97
*[JavaScript interop](#javascript-interop)
98
-
*[Blazor Server circuit handlers](#blazor-server-circuit-handlers)
99
-
*[Blazor Server circuit disposal](#blazor-server-circuit-disposal)
100
98
*[Blazor Server rerendering](#blazor-server-prerendering)
101
99
102
100
The preceding unhandled exceptions are described in the following sections of this article.
@@ -184,56 +182,6 @@ You have the option of using error handling code on either the .NET side or the
184
182
185
183
For more information, see <xref:blazor/javascript-interop>.
186
184
187
-
### Blazor Server circuit handlers
188
-
189
-
Blazor Server allows code to define a *circuit handler*, which allows running code on changes to the state of a user's circuit. A circuit handler is implemented by deriving from `CircuitHandler` and registering the class in the app's service container. The following example of a circuit handler tracks open SignalR connections:
Circuit handlers are registered using DI. Scoped instances are created per instance of a circuit. Using the `TrackingCircuitHandler` in the preceding example, a singleton service is created because the state of all circuits must be tracked:
If a custom circuit handler's methods throw an unhandled exception, the exception is fatal to the Blazor Server circuit. To tolerate exceptions in a handler's code or called methods, wrap the code in one or more [try-catch](/dotnet/csharp/language-reference/keywords/try-catch) statements with error handling and logging.
232
-
233
-
### Blazor Server circuit disposal
234
-
235
-
When a circuit ends because a user has disconnected and the framework is cleaning up the circuit state, the framework disposes of the circuit's DI scope. Disposing the scope disposes any circuit-scoped DI services that implement <xref:System.IDisposable?displayProperty=fullName>. If any DI service throws an unhandled exception during disposal, the framework logs the exception.
236
-
237
185
### Blazor Server prerendering
238
186
239
187
Blazor components can be prerendered using the `Component` Tag Helper so that their rendered HTML markup is returned as part of the user's initial HTTP request. This works by:
Copy file name to clipboardExpand all lines: aspnetcore/blazor/hosting-models.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Understand Blazor WebAssembly and Blazor Server hosting models.
5
5
monikerRange: '>= aspnetcore-3.1'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 02/12/2020
8
+
ms.date: 02/18/2020
9
9
no-loc: [Blazor, SignalR]
10
10
uid: blazor/hosting-models
11
11
---
@@ -115,6 +115,8 @@ Each browser screen (browser tab or iframe) that is connected to a Blazor Server
115
115
116
116
Blazor considers closing a browser tab or navigating to an external URL a *graceful* termination. In the event of a graceful termination, the circuit and associated resources are immediately released. A client may also disconnect non-gracefully, for instance due to a network interruption. Blazor Server stores disconnected circuits for a configurable interval to allow the client to reconnect.
117
117
118
+
Blazor Server allows code to define a *circuit handler*, which allows running code on changes to the state of a user's circuit. For more information, see <xref:blazor/advanced-scenarios#blazor-server-circuit-handler>.
119
+
118
120
### UI Latency
119
121
120
122
UI latency is the time it takes from an initiated action to the time the UI is updated. Smaller values for UI latency are imperative for an app to feel responsive to a user. In a Blazor Server app, each action is sent to the server, processed, and a UI diff is sent back. Consequently, UI latency is the sum of network latency and the server latency in processing the action.
0 commit comments