-
Slow data loading in @if(loaded)
{
<p>Done!</p>
}
else
{
<p>Loading ...</p>
}
@code {
private bool loaded = false;
protected override async Task OnInitializedAsync()
{
await Task.Delay(2000);
loaded = true;
}
} Unfortunately, when the user first visits the page, the page does not get rendered until the Task in Once the page is rendered the first them, switching between the pages works as expected. Questions:
See attached video where you can see the initial 2 second delay when loading the app: blazor-slow.mp4 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
display iframe of your choosing until you have something to show |
Beta Was this translation helpful? Give feedback.
-
I investigated this further and now it makes perfect sense. This makes it perfectly clear why I see this initial delay when I press "F5" in the browser. |
Beta Was this translation helpful? Give feedback.
I investigated this further and now it makes perfect sense.
I used the BlazorServer template which renders the component with "ServerPrerendered". So on the first request the component is rendered on the server and html is returned. Then the app initialises the websocket circuit and renders again using the websocket connection. It is configured in "_Host.cshtml".
This makes it perfectly clear why I see this initial delay when I press "F5" in the browser.
If I change the "render-mode" to "server", the app responds immediately and everything is as expected.