Skip to content

Commit 0178974

Browse files
authored
Merge pull request #34160 from dotnet/main
2 parents 5563624 + d7965e3 commit 0178974

File tree

16 files changed

+120
-82
lines changed

16 files changed

+120
-82
lines changed

aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ All existing components can still be used with static SSR. However, the cost of
2929

3030
†There's a special exception for the `@onsubmit` event handler for forms, which is always functional, regardless of render mode.
3131

32-
This is equivalent to how components behave during [prerendering](xref:blazor/fundamentals/index#client-and-server-rendering-concepts), before a Blazor circuit or the .NET WebAssembly runtime is started.
32+
This is equivalent to how components behave during [prerendering](xref:blazor/fundamentals/index#client-and-server-rendering-concepts), before Blazor's SignalR circuit or the .NET WebAssembly runtime is started.
3333

3434
For components whose only role is to produce read-only DOM content, these behaviors for static SSR are completely sufficient. However, library authors must consider what approach to take when including interactive components in their libraries.
3535

aspnetcore/blazor/components/integration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ The persisted prerendered state is transferred to the client, where it's used to
536536

537537
## Prerendered state size and SignalR message size limit
538538

539-
A large prerendered state size may exceed the SignalR circuit message size limit, which results in the following:
539+
A large prerendered state size may exceed Blazor's SignalR circuit message size limit, which results in the following:
540540

541541
* The SignalR circuit fails to initialize with an error on the client: :::no-loc text="Circuit host not initialized.":::
542542
* The reconnection UI on the client appears when the circuit fails. Recovery isn't possible.
@@ -1055,7 +1055,7 @@ The persisted prerendered state is transferred to the client, where it's used to
10551055

10561056
## Prerendered state size and SignalR message size limit
10571057

1058-
A large prerendered state size may exceed the SignalR circuit message size limit, which results in the following:
1058+
A large prerendered state size may exceed Blazor's SignalR circuit message size limit, which results in the following:
10591059

10601060
* The SignalR circuit fails to initialize with an error on the client: :::no-loc text="Circuit host not initialized.":::
10611061
* The reconnection UI on the client appears when the circuit fails. Recovery isn't possible.
@@ -1487,7 +1487,7 @@ For more information, see <xref:blazor/components/index#class-name-and-namespace
14871487

14881488
## Prerendered state size and SignalR message size limit
14891489

1490-
A large prerendered state size may exceed the SignalR circuit message size limit, which results in the following:
1490+
A large prerendered state size may exceed Blazor's SignalR circuit message size limit, which results in the following:
14911491

14921492
* The SignalR circuit fails to initialize with an error on the client: :::no-loc text="Circuit host not initialized.":::
14931493
* The reconnection UI on the client appears when the circuit fails. Recovery isn't possible.
@@ -1917,7 +1917,7 @@ For more information, see <xref:blazor/components/index#class-name-and-namespace
19171917

19181918
## Prerendered state size and SignalR message size limit
19191919

1920-
A large prerendered state size may exceed the SignalR circuit message size limit, which results in the following:
1920+
A large prerendered state size may exceed Blazor's SignalR circuit message size limit, which results in the following:
19211921

19221922
* The SignalR circuit fails to initialize with an error on the client: :::no-loc text="Circuit host not initialized.":::
19231923
* The reconnection UI on the client appears when the circuit fails. Recovery isn't possible.

aspnetcore/blazor/components/lifecycle.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,15 @@ When [anonymous functions](/dotnet/csharp/programming-guide/statements-expressio
943943

944944
For more information, see [Cleaning up unmanaged resources](/dotnet/standard/garbage-collection/unmanaged) and the topics that follow it on implementing the `Dispose` and `DisposeAsync` methods.
945945

946+
### Disposal during JS interop
947+
948+
Trap <xref:Microsoft.JSInterop.JSDisconnectedException> in potential cases where loss of Blazor's SignalR circuit prevents JS interop calls and results an unhandled exception.
949+
950+
For more information, see the following resources:
951+
952+
* [JavaScript isolation in JavaScript modules](xref:blazor/js-interop/call-javascript-from-dotnet#javascript-isolation-in-javascript-modules)
953+
* [JavaScript interop calls without a circuit](xref:blazor/js-interop/index#javascript-interop-calls-without-a-circuit)
954+
946955
## Cancelable background work
947956

948957
Components often perform long-running background work, such as making network calls (<xref:System.Net.Http.HttpClient>) and interacting with databases. It's desirable to stop the background work to conserve system resources in several situations. For example, background asynchronous operations don't automatically stop when a user navigates away from a component.

aspnetcore/blazor/components/render-modes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ In the following example, the `SharedMessage` component is interactive over a Si
535535

536536
In the following example, both `SharedMessage` components are prerendered and appear when the page is displayed in the browser.
537537

538-
* The first `SharedMessage` component with interactive server-side rendering (interactive SSR) is interactive after the SignalR circuit is established.
538+
* The first `SharedMessage` component with interactive server-side rendering (interactive SSR) is interactive after Blazor's SignalR circuit is established.
539539
* The second `SharedMessage` component with client-side rendering (CSR) is interactive *after* the Blazor app bundle is downloaded and the .NET runtime is active on the client.
540540

541541
`RenderMode7.razor`:

aspnetcore/blazor/fundamentals/signalr.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ If prerendering is configured, prerendering occurs before the client connection
162162

163163
## Prerendered state size and SignalR message size limit
164164

165-
A large prerendered state size may exceed the SignalR circuit message size limit, which results in the following:
165+
A large prerendered state size may exceed Blazor's SignalR circuit message size limit, which results in the following:
166166

167167
* The SignalR circuit fails to initialize with an error on the client: :::no-loc text="Circuit host not initialized.":::
168168
* The reconnection UI on the client appears when the circuit fails. Recovery isn't possible.
@@ -768,25 +768,25 @@ Circuit activity handlers also provide an approach for accessing scoped Blazor s
768768

769769
:::moniker range=">= aspnetcore-8.0"
770770

771-
Configure the manual start of a Blazor app's SignalR circuit in the `App.razor` file of a Blazor Web App:
771+
Configure the manual start of Blazor's SignalR circuit in the `App.razor` file of a Blazor Web App:
772772

773773
:::moniker-end
774774

775775
:::moniker range=">= aspnetcore-7.0 < aspnetcore-8.0"
776776

777-
Configure the manual start of a Blazor app's SignalR circuit in the `Pages/_Host.cshtml` file (Blazor Server):
777+
Configure the manual start of Blazor's SignalR circuit in the `Pages/_Host.cshtml` file (Blazor Server):
778778

779779
:::moniker-end
780780

781781
:::moniker range=">= aspnetcore-6.0 < aspnetcore-7.0"
782782

783-
Configure the manual start of a Blazor app's SignalR circuit in the `Pages/_Layout.cshtml` file (Blazor Server):
783+
Configure the manual start of Blazor's SignalR circuit in the `Pages/_Layout.cshtml` file (Blazor Server):
784784

785785
:::moniker-end
786786

787787
:::moniker range="< aspnetcore-6.0"
788788

789-
Configure the manual start of a Blazor app's SignalR circuit in the `Pages/_Host.cshtml` file (Blazor Server):
789+
Configure the manual start of Blazor's SignalR circuit in the `Pages/_Host.cshtml` file (Blazor Server):
790790

791791
:::moniker-end
792792

@@ -1394,9 +1394,9 @@ protected override async Task OnInitializedAsync()
13941394

13951395
:::moniker range=">= aspnetcore-5.0"
13961396

1397-
## Disconnect the Blazor circuit from the client
1397+
## Disconnect Blazor's SignalR circuit from the client
13981398

1399-
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)):
1399+
Blazor's SignalR 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)):
14001400

14011401
```javascript
14021402
window.addEventListener('pagehide', () => {

aspnetcore/blazor/hybrid/static-files.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,13 @@ In a Razor component:
294294
{
295295
if (module is not null)
296296
{
297-
await module.DisposeAsync();
297+
try
298+
{
299+
await module.DisposeAsync();
300+
}
301+
catch (JSDisconnectedException)
302+
{
303+
}
298304
}
299305
}
300306
}

aspnetcore/blazor/includes/js-interop/circuit-disconnection.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

aspnetcore/blazor/includes/js-interop/js-collocation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ The following `JsCollocation2` component's `OnAfterRenderAsync` method loads a J
130130
{
131131
if (module is not null)
132132
{
133-
await module.DisposeAsync();
133+
try
134+
{
135+
await module.DisposeAsync();
136+
}
137+
catch (JSDisconnectedException)
138+
{
139+
}
134140
}
135141
}
136142
}

aspnetcore/blazor/includes/js-interop/synchronous-js-interop-call-js.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ When working with <xref:Microsoft.JSInterop.IJSObjectReference> in ASP.NET Core
4747
{
4848
if (module is not null)
4949
{
50-
await module.DisposeAsync();
50+
try
51+
{
52+
await module.DisposeAsync();
53+
}
54+
catch (JSDisconnectedException)
55+
{
56+
}
5157
}
5258
}
5359
}

aspnetcore/blazor/javascript-interoperability/call-dotnet-from-javascript.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,13 @@ In the following component, the `Trigger JS function` buttons call JS functions
563563
{
564564
if (module is not null)
565565
{
566-
await module.DisposeAsync();
566+
try
567+
{
568+
await module.DisposeAsync();
569+
}
570+
catch (JSDisconnectedException)
571+
{
572+
}
567573
}
568574
569575
dotNetHelper?.Dispose();

0 commit comments

Comments
 (0)