Beware of the Interactive Auto Render Mode in Blazor in .NET 8! It might break your app! ⚠️

Поделиться
HTML-код
  • Опубликовано: 27 сен 2024
  • 🚀 Join the .NET Web Academy: learn.dotnetwe...
    🚀 Get the .NET 8 Web Dev Jump-Start Course for FREE: dotnet8.patric...
    🐦 Let's get social on Twitter/X: / _patrickgod
    🔗 Let's connect on LinkedIn: / patrickgod
    #DotNet #Blazor #AspNetCore

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

  • @der-mit-dem-rotwild-tanzt
    @der-mit-dem-rotwild-tanzt 4 дня назад +3

    This rendermode stuff is really confusing. Thanks for this great explanation and sample!

  • @imSkod
    @imSkod 4 дня назад +1

    I think this title should just be like 'how to use services in Auto rendermode' or something similar. Good explanation and video though

  • @tajmaut2
    @tajmaut2 4 дня назад +1

    what about it in MudBlazor??

    • @samerelsahih
      @samerelsahih 4 дня назад

      Total chaos. I still can't seem to run it correctly on both server and client side

    • @jaytandon
      @jaytandon 4 дня назад

      Agreed, hopefully dotnet 9 makes Mudblazor work better

  • @Hasan10-oh7vl
    @Hasan10-oh7vl 3 дня назад

    Love ittt!!!
    You need a video editor bro ?
    I can do a sample video 👊🏽

  • @mtranchi
    @mtranchi 4 дня назад +2

    No way I could bring myself to make two database calls for every page load across every web app I run.

    • @kijanawoodard
      @kijanawoodard 4 дня назад +1

      Wouldn’t it just be for the initial load and then you’re pure web assembly after that?

    • @mtranchi
      @mtranchi 4 дня назад

      @@kijanawoodard No it doesn't work that way. Put a break point on your controller and you'll see the endpoint gets hit twice: once from the server, again from the client... though... i already can't remember how Patrick set up his code, so not sure about his implementation, lol.
      however, there's a super simple check built in to Blazor 8 where you can check if the component is being rendered on the server or in the web browser. You can use that to (pseudo code) "if(Environment.IsBrowser)" in your OnInitializedAsync to decide whether you want the db to be hit on the server or in the browser. Comment on this, when i get a chance, i'll find it, post it back here

    • @markhill1066
      @markhill1066 3 дня назад +2

      Your not supposed to, the first database call which happens via SSR fetches the data which is then added to the persistent state. When the component/page is loaded in wasm it loads data from the persistent state. So SSR is for the initial load, WASM handles incremental updates.

    • @mtranchi
      @mtranchi 3 дня назад

      @@markhill1066That's the way it should be, but not according to my break-point when debugging. The `controller` `action` that fetches the data from the db gets hit twice, 100% certain it is so in Blazor 8 because i've spent copious hours working to eliminate one of the calls.

  • @julienbarach6620
    @julienbarach6620 4 дня назад +7

    Finally someone talking about the main issue with the Auto mode. Blazor templates are not as ready to go (except for Server) as they were with .Net 7.
    New developers will think that Auto is the default mode and the best of both worlds but you are always dealing with two modes (Server and WASM) that are fondamentally different and no one is telling you that it's dangerous.
    API calls are one example but you'll find even more complex issues when you'll want to use localSotrage for instance.
    So be careful when you want to use the Auto mode. It's sexy on the paper but it can lead to big headhaches and too much complexity for nothing.

    • @alexmadnix
      @alexmadnix 4 дня назад

      Useful information!☺

  • @Conjuredfilms
    @Conjuredfilms 3 дня назад

    Hi Patrick I saw you're looking for an editor! I'm available and emailing you.

  • @webmaster4095
    @webmaster4095 День назад

    Привет, Мир! Я начал использовать Blazor 8 и столкнулся с проблемой контроля за персистентностью состояния при использовании режима AutoInteractive, где почитать/посмотреть лучшие практики по данному режиму рендеринга?

  • @bou7eliw
    @bou7eliw День назад

    Hi, please could show us how we can do an authentification using active directory? Please

  • @krrk7356
    @krrk7356 День назад

    How do you think it is possible to turn these 2 separate services into server and client. For separate instances of the mediator. We inject the mediator into the component. If it runs on the server then it uses the corresponding handler. If on the client, then the corresponding handler does the http query. And the controller uses the mediator from the server.

    • @webmaster4095
      @webmaster4095 День назад

      Привет, рекомендую посмотреть портированную библиотеку redux-blazor. Она отлично работает с обновлением состояния.