Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect if the code is executing for the first time when entering the page in blazor server side #44903

Open
1 task done
Alerinos opened this issue Nov 6, 2022 · 3 comments
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

Comments

@Alerinos
Copy link

Alerinos commented Nov 6, 2022

Is there an existing issue for this?

  • I have searched the existing issues

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:

  1. Execute code on first entry (server side)
  2. Will execute the same code again after loading the page or moving dynamically (e.g. to a subpage)

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:

protected override async Task OnInitializedAsync()
  {
  if(AppState.ServerRendering == false){
  // Code that does not require rendering during server rendering
  }
}

or

protected override async Task OnInitializedDynamicAsync(){
// Code that does not require rendering during server rendering
}

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

@Alerinos Alerinos changed the title Detect server side and dynamic loading on blazor server side Detect if the code is executing for the first time when entering the page in blazor server side Nov 6, 2022
@TanayParikh TanayParikh added area-blazor Includes: Blazor, Razor Components feature-rendering Features dealing with how blazor renders components labels Nov 7, 2022
@javiercn javiercn added this to the Backlog milestone Nov 7, 2022
@ghost
Copy link

ghost commented Nov 7, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@MackinnonBuck
Copy link
Member

@Alerinos I think this might be a dupe of #49401. Does that seem right to you?

@ghost
Copy link

ghost commented Jan 3, 2024

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mkArtakMSFT mkArtakMSFT added enhancement This issue represents an ask for new feature or an enhancement to an existing one and removed Pillar: Complete Blazor Web labels Jan 3, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

6 participants