Skip to content

Commit 0336af2

Browse files
author
Safia Abdalla
authored
[.NET 5 RC1] Add content on customizing client-side disconnect (#20032)
1 parent 6a6a632 commit 0336af2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

aspnetcore/blazor/fundamentals/additional-scenarios.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,15 @@ Customize the delay before the reconnection display appears by setting the `tran
274274
}
275275
```
276276

277-
::: moniker-end
277+
## Disconnect the Blazor circuit from the client
278+
279+
By default, a Blazor circuit is disconnected when the [`unload` page event](https://developer.mozilla.org/docs/Web/API/Window/unload_event) is triggered. To disconnect the circuit for other scenarios on the client, invoke `Blazor.disconnect` in the appropriate event handler. In the following example, the circuit is disconnected when the page is hidden ([`pagehide` event](https://developer.mozilla.org/docs/Web/API/Window/pagehide_event)):
280+
281+
```javascript
282+
window.addEventListener('pagehide', () => {
283+
Blazor.disconnect();
284+
});
285+
```
278286

279287
## Influence HTML `<head>` tag elements
280288

@@ -307,6 +315,8 @@ When one of the framework components is used in a child component, the rendered
307315
* Can be modified by application state. A hard-coded HTML tag can't be modified by application state.
308316
* Is removed from the HTML `<head>` when the parent component is no longer rendered.
309317

318+
::: moniker-end
319+
310320
## Static files
311321

312322
*This section applies to Blazor Server.*

0 commit comments

Comments
 (0)