From cc368c8e0856e087d93f65dac9fa4fed045199b4 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 30 Sep 2019 20:37:46 -0700 Subject: [PATCH] Prevent null refs in RemoteJSRuntime Fixes https://github.com/aspnet/AspNetCore/issues/13396 --- src/Components/Server/src/Circuits/RemoteJSRuntime.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Components/Server/src/Circuits/RemoteJSRuntime.cs b/src/Components/Server/src/Circuits/RemoteJSRuntime.cs index ef42dcaa72..0ef78bcf0f 100644 --- a/src/Components/Server/src/Circuits/RemoteJSRuntime.cs +++ b/src/Components/Server/src/Circuits/RemoteJSRuntime.cs @@ -70,12 +70,12 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits protected override void BeginInvokeJS(long asyncHandle, string identifier, string argsJson) { - if (!_clientProxy.Connected) + if (_clientProxy is null) { - throw new InvalidOperationException("JavaScript interop calls cannot be issued at this time. This is because the component is being " + - "prerendered and the page has not yet loaded in the browser or because the circuit is currently disconnected. " + - "Components must wrap any JavaScript interop calls in conditional logic to ensure those interop calls are not " + - "attempted during prerendering or while the client is disconnected."); + throw new InvalidOperationException( + "JavaScript interop calls cannot be issued at this time. This is because the component is being " + + $"statically rendererd. When prerendering is enabled, JavaScript interop calls can only be performed " + + $"during the OnAfterRenderAsync lifecycle method."); } Log.BeginInvokeJS(_logger, asyncHandle, identifier);