In my blazor-server-side app I am calling JSRuntime.InvokeAsync to open static content in a popup window:
await _jsRuntime.InvokeAsync<object>("open", "/help/help.html", "_blank");
It works, but after some time (probably a timeout?) a TaskCanceledException is thrown. I tried calling InvokeVoidAsync, but the effect is the same. I can fix this by catching and ignoring the exception or by removing "await", but I was hoping for a cleaner solution that does not give me complier warnings.
Try specify cancellationToken as CancellationToken.None
await _jsRuntime.InvokeAsync<object>("open", System.Threading.CancellationToken.None, "/help/help.html", "_blank");
A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts (DefaultAsyncTimeout) from being applied.
Documenation here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With