One irksome problem that plagues many Blazor Server programs is that the circuit status is lost once a user disconnects. This implies that the user must restart, counters are reset, and form data is lost.
Circuit Persistence, a revolutionary feature that enables your component state to withstand reconnections, is introduced by Blazor with.NET 10. We’ll examine what it is in this post and use a straightforward example to demonstrate how it works.
Problem in Previous Versions
Here’s a basic counter component in older Blazor versions:
If the connection to the server drops and reconnects, it currentCount
resets to 0. That’s frustrating for users. So Blazor 10 solved this problem below
Solution in Blazor 10
Blazor 10 adds the attribute [SupplyParameterFromPersistentComponentState]
to help persist the component state. Let’s rewrite the counter using it:
When you lose the connection, see the image below, and the Current count is 3.
Now, even if the server connection drops, the counter value will continue from where the user left off after re-connection, and the Current count is 4
Benefits of Circuit Persistence
- No unexpected resets – state survives connection loss.
- Great for banking, e-commerce, and form-heavy apps.
- Improves user experience significantly.
Conclusion
Blazor 10 takes a big step forward in reliability with Circuit Persistence. If you’re building Blazor Server apps, this feature can dramatically improve the user experience by preventing frustrating state resets. Start experimenting with it today, and make your apps more resilient and user-friendly!
ASP.NET 10.0 Hosting Recommendation
ASP.NET is a powerful platform for creating web applications and services. You must be comfortable with JavaScript, HTML, CSS, and C# before developing a web application in ASP.NET. On the market, there are thousands of web hosting companies providing ASP.NET Hosting. But, only very few web hosting companies could provide high quality ASP.NET hosting solution.
ASP.NET is the best development language in Windows platform, which is released by Microsoft and widely used to build all types of dynamic Web sites and XML Web services. With this article, we’re going to help you to find the best ASP.NET Hosting solution in Europe based on reliability, features, price, performance and technical support. After we reviewed about 30+ ASP.NET hosting providers in Europe, our Best ASP.NET Hosting Award in Europe goes to HostForLIFE.eu, one of the fastest growing private companies and one of the most reliable hosting providers in Europe.