blazorblazor-server-side

Blazor - should I read in my data in OnInitializedAsync() or OnAfterRenderAsync(true)


When my page loads, generally I am hitting the database to get the data for that page. It's not a ton of data so not the end of the world if I read it twice, but better to read it once.

The page can render without this data, but it's going to look very empty/sparse if it's viewed without the data. Not wrong, no errors, but empty.

So, when is the suggested place to load the data for the page? And if it's OnInitializedAsync(), should I have a boolean so I load the first time and subsequent times I know I already have it?


Solution

  • See this picture