Allan
Blazor Server: recommendations for Production use
Hello! I'm building a Blazor Server app that's gonna be used on mobile browsers. I have some questions to properly configure it and avoid as much issues as possible. I noticed when you are not focused on the browser on mobile, the WebSocket connections are interrupted, leading to timeouts and reconnects.
The main issue I have is that when it timeouts, it attempts to reconnect (good thing!) but once it has reconnected, it re-renders the page entirely, leading to things like forms being lost. Is the good practice implementing this: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerendering-and-integration?view=aspnetcore-7.0&pivots=server#persist-prerendered-state or is there something I have missed?
I'm also looking to know what I should do regarding handshake and keepalive timeouts... thanks!
4 replies
❔ Blazor Server + Custom SignalR hub
Hello,
I use a hub for receiving messages from the server at specific moments. When I close my tab or leave the website, the OnDisconnected method is NEVER called in the Hub. The DisposeAsync method in the blazor component is also never called. I also tried to reduce keepalives/timeouts etc. but it does never trigger.
Is it an actual known issue? Am I doing something wrong?
I followed this for setting up everything: https://learn.microsoft.com/en-us/aspnet/core/blazor/tutorials/signalr-blazor?view=aspnetcore-7.0&tabs=visual-studio&pivots=server
edit: setting the timeouts on the hubconnection seems to have effects... what are the default values?
2 replies
Questions regarding Blazor (WASM, Server etc.)
Hello, I'm starting a tiny project and I wanted to explore the possibilities of Blazor. I have some questions about the different possible things with Blazor because there's something I don't understand properly between the client-side and server-side.
I first made a WASM Blazor app, so it seems everything is done client-side. I wanted to know how to make server-side treatments (such as Database requests):
- Do I have to create my own controllers in the app?
- When you inject Services within your page, is the code within the service executed server-side or client-side? Can you chose this behaviour?
Then, is it bad to make a WASM Blazor App if I'm going to make some things server-side? Should I instead make a Blazor Server app, or a Hosted WASM Blazor app?
6 replies
Serialize a JsonDocument/JsonElement with STJ
I have a class with an
object
property. When deserializing something into this class, it deserializes it as a JsonElement. When trying to serialize it back to raw JSON, it will serialize the actual properties of JsonElement
or JsonDocument
... Any idea?38 replies