The Biggest ISSUE With Blazor (and how to fix it)

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

Комментарии • 61

  • @Codewrinkles
    @Codewrinkles  Год назад +8

    A short clarification. According MS documentation, there is a way for stateful reconnects that could potentially also be applied to this scenarios. And this would be to use some kind of memory stream to keep track of the loaded data and when the render process goes the second time through OnInitialized you can get the data from the stream directly. However, I don't think that a simple task in all modern SPA frameworks (like initializing data) should required this level of complexity in our applications.

  • @StateHasChanged
    @StateHasChanged Год назад +11

    I love Blazor 8, but MS needs to do a better job of dog fooding their stuff. When I ported my Blazor Server app to the Blazor Web template, I had this same issue. Took me a good hour of internet research to find this same workaround. For my app, I set this globally on the routes component, as it is a SPA.

    • @Tekner436
      @Tekner436 Год назад +1

      it's crazy that other ssr frameworks have things like this figured out

  • @carolinacordero6616
    @carolinacordero6616 8 месяцев назад +1

    On a fresh new application based on the default Blazor Web App Template, I never see the "Loading..." message at 1:28, and at Network tab, the request shows as: Status (pending), not immediately 200 as in your demo. Can anyone help me?

    • @justfair4181
      @justfair4181 6 месяцев назад +1

      Yes , you are right. This video is a modified Blazor app and totally incorrect.

  • @androidsavior
    @androidsavior 16 дней назад

    the biggest two issues of blazor wasm are :
    - startup time (caching enabled - empty App.razor - empty Program.cs) 1.5s to render an empty page.
    - hot reloading issues during development is a nightmare
    I've tried everything that I could to optimize the startup time for a completely empty blazor wasm app, 1.5s is what i get. So with a real application the wait time can be +4 or +5 seconds which is not acceptable at all :(

  • @majormartintibor
    @majormartintibor Год назад +3

    Very helpful video, thanks!

  • @geraldmaale
    @geraldmaale Год назад +3

    For whatever reason, I couldn't reproduce this behaviour using the Blazor Web App with server interactivity location set to Per page/component. The breakpoint set on the OnInitializedAsync method was not hit twice but once.
    Did you miss something or I missed something?

    • @Codewrinkles
      @Codewrinkles  Год назад

      I'm not the only one complaining about this issue. I'm not sure why you couldn't reproduce it. It's just as easy as having the template and making the delay 5 seconds and adding @rendermode InteractiveServer. It's weird however and gives me food for thought.

    • @Codewrinkles
      @Codewrinkles  Год назад +1

      Are you sure you added @rendermode InteractiveServer? The rendermode needs to be activated manually. By default everything is SSR. The first demo I made in the video, everything was working, but it was without interactivity

    • @geraldmaale
      @geraldmaale Год назад +1

      @@Codewrinkles Yeah my bad., I overlooked that part. After that correction, it worked as in your demo.
      Based on the advise given by DanRoth and Co., I decided to always make a component and not slap the @rendermode in them.

    • @Codewrinkles
      @Codewrinkles  Год назад

      Yeah, but this is not always possible. I mentioned this approach in the "Everything you need to know about Blazor" video. My approach is to also try to keep everything as much SSR as possible. However, sometimes you need to communicate between parent and child components and in that case you can't escape this problem every time.

    • @robdevoer1
      @robdevoer1 Год назад

      @@geraldmaale This way it will not render correctly when calling the component from a link or menu. You'll need the @rendermode specified within the component if you also route to it.

  • @dhanarajdavid7070
    @dhanarajdavid7070 9 месяцев назад

    Thank you for the valuable information. I have spent many hours to resolve this problem

  • @AmerBakeer
    @AmerBakeer Год назад +2

    Wonderful !! Thank you for the valuable information. It will help me solve many problems.

  • @AmerBakeer
    @AmerBakeer 7 месяцев назад +1

    Unfortunately, I think disabling/bypassing Pre-rendering harms SEO and prevents search engines from seeing/indexing page content, even though the solution is useful from a UX point of view.
    I eventually had to re-enable it because search engines saw pages as empty.
    Are you aware of a better solution that still allows prerendering to remain enabled?

    • @justfair4181
      @justfair4181 6 месяцев назад +2

      You're right: prerendering can help with search engine optimization (SEO) since the initial HTML content is generated on the server and can be crawled by search engines

  • @abhayprince
    @abhayprince Год назад +4

    For this issue,I have discussed the PersistComponentState approach in detail ruclips.net/video/qQ91rdMgIMM/видео.html

  • @shabanelmogy7912
    @shabanelmogy7912 Год назад

    how can i sync between sqlite on mobile offline and remote database (restapi with sql server ) ?

  • @codecam9213
    @codecam9213 11 месяцев назад

    how to manually authenticate with blazor SSR

  • @simond3752
    @simond3752 Год назад

    I tried to use this, but I found out that my login page is blank (with background) if prerendering is disabled. Is it a bug or is it something wrong? Thank you for all your hard work!

  • @Duelweb
    @Duelweb Год назад +1

    Super stuff, thanks!

  • @sokratis981
    @sokratis981 Год назад

    Thank you very much! In a global server mode project I successfully applied the changes in App.Razor component in order to avoid OnInitialized be called twice. It worked fine but if I use Individual Accounts Authentication a problem with login has occurs. After searching, I found that the problem is that http context is null and the login page is not loading. What can be done?

    • @Codewrinkles
      @Codewrinkles  Год назад +1

      Yes, activating global serber mode effectively turns your app in a Blazor Server app. Please look up the Blazor Server playlist on the channel since I have plenty of videos on Blazor Server Authentication.

  • @luciannaie
    @luciannaie Год назад

    nice workaround. I'm sure I'll use it

  • @liammcmullen4497
    @liammcmullen4497 8 месяцев назад

    thanks for a big heads-up

  • @MarvinKleinMusic
    @MarvinKleinMusic Год назад

    Could you do a video about Authentification without using Identity in Blazor?

  • @ИванБармин-ю1т
    @ИванБармин-ю1т Год назад +1

    why not just make preconfigured global static class for configured render modes? same as RenderMode set in _imports.razor

    • @Codewrinkles
      @Codewrinkles  Год назад

      I don't quite get what this would do other then my entire app would become interactively rendered. What am mI missing?

  • @AryaDinesh-jd5du
    @AryaDinesh-jd5du 6 месяцев назад +1

    When the page is refreshed, the issue is not resolved even though it works for the initial rendering.

    • @justfair4181
      @justfair4181 6 месяцев назад +1

      You're right. This video is not up to date or even correct. All comments saying 'thank you' to the author are owner's friends probably.

  • @grimmersnee
    @grimmersnee Год назад

    Nice. I'm sure I will use this soon. You have also lost a l ot of weight, whatever u are doing is working. Great job man

  • @VladislavAntonyuk
    @VladislavAntonyuk 9 месяцев назад +1

    what is the down side of this approach? There may be a reason why Microsoft set pretender default value equals true.

  • @MrSurfsAlot
    @MrSurfsAlot Год назад +1

    I'm making an app where SEO is very important so don't think this will be a viable work around for me unfortunately...

    • @Codewrinkles
      @Codewrinkles  Год назад +6

      I guess you will need to define which is more important: SEO or data loading twice. An alternate workaround would be to move the Weather into an entire new component. Then have the @rendermode set on the component, not on the page level. This will allow you to still be SEO-friendly and also avoi loading data twice.

  • @emcwealth
    @emcwealth 10 месяцев назад

    You can actually move the data load and delay into onafterrender instead oninit, first render only of course

    • @Codewrinkles
      @Codewrinkles  10 месяцев назад

      That is not an optimal experience in my opinion since at that point the HTML is already rendered. There will be strange flickers of the UI that end users will experience.

    • @emcwealth
      @emcwealth 10 месяцев назад

      @Codewrinkles there are no strange flickers... I write 100% of my code this way in blazor wasm... screen renders with loading or spinner while data loads and then is presented to user on screen... ux is wonderful at that point... in fact doing data loads in onitnit causes the odd behaviors

  • @user-fqlt
    @user-fqlt 11 месяцев назад

    Thanks very useful. +1 sub

  • @codeDotnet
    @codeDotnet 9 месяцев назад

    How To Add Localization In Blazor | Multi-Language Support with arabic and english or any languages

  • @justfair4181
    @justfair4181 6 месяцев назад +1

    The video is not up to date or is a modified Blazor Server app or even a Blazor Server app created from .NET 7 migrated to .NET8 later. There is no InteractiveServer rendermode in Blazor Server in .NET8 . Also under Pages in the video I am not seeing _Host.cstml file.

    • @Codewrinkles
      @Codewrinkles  6 месяцев назад +2

      Sorry, but you're totally off on this one. The entire model has changed in .NET 8 and everything is SSR by default. Even if youwant to create a Blazor Server application it just creates a Blazor SSR one (for auth components) and adds server interactivity globally via an if check. Same goes for assembly. I also have a video on getting started with Blazor on .NET 8. I think that one might be really useful.

    • @justfair4181
      @justfair4181 6 месяцев назад

      @@Codewrinkles You are right on this word: you're 'totally' wrong. Please read my comments again. I am using .NET since 2003 and these days I'm under . NET 8. so 100% you're wrong.

  • @user-uo7ch2lf3z
    @user-uo7ch2lf3z Год назад +1

    Thank you.
    I hope Microsoft would take this as a bug and it properly fixed.

    • @Codewrinkles
      @Codewrinkles  Год назад

      Strictly speaking, this is not a bug. This is how things are supposed to work in this model. You have a server predener and then an interactive render process. But I agree it's a fairly big inconvenience and should at least be documented in a more proper way.

    • @user-uo7ch2lf3z
      @user-uo7ch2lf3z Год назад

      @@Codewrinkles Besides documentation, there should be a formal way to prevent OnInitalizedAsync() from executing twice.
      Maybe just certain syntatic sugar like:
      @rendermode InteractiveServerNotPrerendered
      Nice quick fix, anyway.

  • @torokcsaba6267
    @torokcsaba6267 3 месяца назад

    király

  • @connectdots
    @connectdots 9 месяцев назад

    hi @codewrinkles does blazor run on IIS or some new webserver?

    • @Codewrinkles
      @Codewrinkles  9 месяцев назад

      Blazor is An #aspnetcore app and therefore it can run wherever you want it to run, just like any other aspnetcore app.

    • @connectdots
      @connectdots 9 месяцев назад

      I mean as is what webserver on windows? IIS? or is there a new webserver?

  • @karilynnscobey731
    @karilynnscobey731 11 месяцев назад

    👍 "promosm"