locked
Blazor issues RRS feed

  • Question

  • User2110873642 posted

    Blazor seems to give amazing functionality.

    but there are a few things i do not understand.

    it seems like blazor is made for server communication when requested from the page, trough user driven input events. It does not seem to be made to push data from the server to the client, when the server has something to tell.

    to get around it, i loop this code below, and everything seems to work. at a ping of 15 ms. (66 hz) the page continuesly updates with the values in the server cashe.

       this.StateHasChanged();
       await Task.Delay(1);

    it works fine, but is this really the simplest way to do it? or is there something im missing? its a little hacky to me.

    additionally. if webforms is being criticised, how come that blazor doesnt have an MVC pattern? or is it just that server controls and viewstate are the reason for critisism?

    is blazor even gonna get integrated in MVC by default without my hacky surgery?

    Friday, July 17, 2020 12:56 PM

All replies

  • User475983607 posted

    it seems like blazor is made for server communication when requested from the page, trough user driven input events. It does not seem to be made to push data from the server to the client, when the server has something to tell.

    Use SignalR for responding to events in the web server.  SignalR uses web sockets which is a persistent connection between the browser and server.   SignalRis is very mature with a lot of supporting documentation.

    https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-3.1

    Friday, July 17, 2020 2:20 PM
  • User2110873642 posted

    blazer already uses signal-r. i want to know how to use its existing implementation. not to create a second layer, which might not even be possible.

    Friday, July 17, 2020 10:34 PM
  • User475983607 posted

    fazioliamboina

    blazer already uses signal-r. i want to know how to use its existing implementation. not to create a second layer, which might not even be possible.

    It really helps if you read the docs rather than making assumptions.

    There are two version of Blazor or hosting models.  Server and web assembly.   Web assembly runs in the browser.  Server runs on a web server UI updates, events and JavaScript calls are handled over SignalR.

    https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-3.1

    You are correct that Blazor Server uses SignalR.  The problem or mystery is the SingnalR configuration is wrapped up in a middleware.  If you want to catch events on the server it is very help full to understand SingalR.  If you have an requirement where the client is a listener for server side events then you might find SignalR is enough.

    Blazor Web Assembly with SignalR is interesting.

    https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr-blazor-webassembly?view=aspnetcore-3.1&tabs=visual-studio

    Saturday, July 18, 2020 10:57 AM