jsakamoto / Toolbelt.Blazor.HeadElement

Head element support (change the document title, "meta" elements such as OGP, and "link" elements) for Blazor apps.
https://demo-blazor-headelement.azurewebsites.net/
Mozilla Public License 2.0
158 stars 11 forks source link

<Link> creates forece reload #35

Open Alerinos opened 1 year ago

Alerinos commented 1 year ago

Using this method causes a heavy reload of the page:

@using Toolbelt.Blazor.HeadElement
<Link Rel="canonical" Href="https://google.pl" />

The problem is described here: https://github.com/dotnet/aspnetcore/issues/15317

What's the problem? In the case of server side rendering, blazor loads the page content and then the async elements are reloaded. This gives us the effect of double page loading.

Only Link has a problem, meta tags work well.

Demo: https://gyazo.com/b36e3ea01ebeefb56e60b524b3b24532

If I don't use or _headElementHelper.SetLinkElementsAsync then the problem disappears.

jsakamoto commented 1 year ago

@Alerinos
Thank you for reporting!

Unfortunately, I could not reproduce the force reloading that you said yet.

My sample project is here:

📦LinkCanonicalTest.zip

image

Could you take a look at my sample project above?

Alerinos commented 1 year ago

I tried to open an issue on the project you submitted. I failed to. It looks like my project uses something that has a dependency on your library. I will try to find a solution and a bug. It is possible that the problem occurs with more data and tags in Head

Once I noticed that something like this happens when you load static files (pictures, background, more css etc). Also now I can see that it is not reloading the files (network). The page just flashes. I think it has to do with the asynchronous solution.

Alerinos commented 1 year ago

I am currently researching this issue. It still exists. This looks like a similar scenario that is in the documentation. https://learn.microsoft.com/en-us/aspnet/core/blazor/components/lifecycle?view=aspnetcore-7.0

@jsakamoto Can you look at the code again? Maybe you missed something. Thanks!

jsakamoto commented 1 year ago

@drma-dev Sorry too late since I was busy watching the .NET Conf 2022 that was held this week. (I live in Japan, so I had to wake up at midnight in the Japan Standard Time zone and keep staying up).

Can you look at the code again?

Ok, but I don't have the confidence to resolve this issue as far as I've gotten limited information below:

Could you disclose the source code of the app that has the problem we are discussing in this thread? Or else, can you create and send me a minimal sample project that can reproduce the same problem?