This code will help you to understand how to InvokeAsync during OnInitAsync never finish in Blazor and why do tasks returned from JSRuntime.
This is a known bug and is resolved in the upcoming release of Blazor Preview 3. [Issue Resolved]
[wwwroot/index.html]
<script> window.interopDuringOnInit = function () { return "Hello World"; } </script>
[Razor]
@code { string Greeting; protected override async Task OnInitializedAsync() { try { Greeting = await JSRuntime.InvokeAsync<string>("interopDuringOnInit"); } catch (Exception ex) { Console.WriteLine("Could not invoke interop during OnInit, " + ex.ToString()); } } }
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
This is a known bug and is resolved in the upcoming release of Blazor Preview 3. [Issue Resolved]
[wwwroot/index.html]
[Razor]
need an explanation for this answer? contact us directly to get an explanation for this answer