Blazor - Page Loads But Code Not Running Until SignalR Connection Opens

Elisheva 1 Reputation point
2022-06-16T15:53:35.23+00:00

When my Blazor page starts up, you can see the page and type in the inputs. However, none of the event handlers get called. After about 2-3 seconds, all of the inputs get cleared and the event handlers start responding.

I think this is happening because the websocket connection wasn't ready when the page loaded.

Is there a way that I can set up the websocket connection earlier or prevent the page from displaying until the websocket connection is set up?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,395 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,686 Reputation points
    2022-06-16T19:51:15.28+00:00

    You appear to be using server pre-render, but not persisting the pre-render state:

    https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerendering-and-integration?view=aspnetcore-6.0&pivots=server