question

michael-5336 avatar image
0 Votes"
michael-5336 asked ADefWebserver answered

Blazor server side. Client side with DB connections

Hello,

I am working on a Blazor server side application.
Now do I use multiple databases on different part of the website.
How is it possible that client A that is on a page that use Database Z stays connected while client B on Database Y is also connected?
Both pages are being build fine and both has a call to the database every second.
So when client A is on the page it is getting updated with the new data from the databse every second. But when client B goes to another page that uses Database Y. Connection to database Z is stopped and client A does not get an updated page anymore (till refresh but than the same goes for client B they don't get an error because of the catch that I use).
Is there a way for every client to keep connected to the database that is needed for that page or pages? So that when client C goes to another page that uses either database Z,Y or maybe even X that they don't interfere with each other?

If there is a tutorial available somewhere please let me know. I've tried a few but couldn't implement it in Blazor server side. If it is not possible let me know as well.
Thanks in advance

windows-server-iisdotnet-aspnet-core-blazor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OlafHelper-2800 avatar image
1 Vote"
OlafHelper-2800 answered

Is there a way for every client to keep connected to the database that is needed for that page or pages?

Not the web client accessing the database, it's the blazor backend and web backend normally work stateless = no permanent connection.

If it is not possible let me know as well.

Indeed; you have to rethink your application design.
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

Unlike regular websites, blazor server apps have dedicated state, tied to the signal/r connection, but not a dedicated thread.

So, there is no technical reason your code won’t work. It sound like you are not managing the database connections properly.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ADefWebserver avatar image
0 Votes"
ADefWebserver answered

You would not have (or need) a separate database for each user.

All your users would use the same database. For a tutorial see: Creating A Step-By-Step End-To-End Database Server-Side Blazor Application (updated to .Net 6)

You can open up the app in multiple web browsers, and create and log in as different users.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.