Detect if the code is executing for the first time when entering the page in blazor server side #44903
Open
1 task done
Labels
area-blazor
Includes: Blazor, Razor Components
enhancement
This issue represents an ask for new feature or an enhancement to an existing one
feature-rendering
Features dealing with how blazor renders components
Milestone
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
Blazor could use the function of detecting the first loading of a component / subpage by the server.
If we use
OnInitializedAsync
it will work like this:If we have a subpage where the code takes longer to load (e.g. we wait for the API), a problem arises. The first load is delayed by this component.
In case we don't want to be indexed by bots, there should be a function like don't do it on server side. We can do a Skeleton and wait for the task to be done.
It is possible to do this by
PersistentComponentState
, but it is not convenient and there are problems with many components (you can call it only once)I propose to do something like this:
or
I also know about the existence of
OnAfterRenderAsync
but it doesn't render the code on the server side.Describe the solution you'd like
Let me know what you think, I think letting the developer decide whether the code is to be rendered server-side or not is a good solution. This will prevent the problem of delaying the entire page by, for example, one component.
Additional context
No response
The text was updated successfully, but these errors were encountered: