Prevent null refs in RemoteJSRuntime

Fixes https://github.com/aspnet/AspNetCore/issues/13396
This commit is contained in:
Pranav K 2019-09-30 20:37:46 -07:00 committed by Artak
parent 29a1d50e02
commit cc368c8e08
1 changed files with 5 additions and 5 deletions

View File

@ -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);