0

I'm trying to hide or show an element on the client by updating a parameter on db. Is that possible with signalR? Or is there any other way to do it? Note: my application is based on asp.net core mvc (entity framework)

togy
  • 15
  • 4

1 Answers1

0

Asp.net core SignalR is used to create real-time web functionality, are you sure you want to achieve this behavior?

"hide or show an element on the client by updating a parameter on db."

For this question, it depends on how you want to hide or show the element, real time or just one time?

If you just want to hide or show the element when page load (one time per page load), you can query the database and get the condition (parameter from the database), and then use an if-else statement to hide or show the element.

If you want to change the element status real-time, you can use SignalR.
Create a scheduled task on the back end and trace the database parameter status, if the parameter changes, call the client method and show or hide the element.

Reference:

Background tasks with hosted services

How can I execute a method every year using BackgroundService in ASP.NET core Application?

Send messages from outside a hub

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30