I needed to do some notification concept for my asp.net project like facebook notifications. if a user added something in database. the notification icon will be +1 and when you click the icon, you'll see who added what to database like fb. so i needed to run SignalR function if database update is OK in codebehind. I'm new in SignalR and trying to figure it out. i'm not working with MVC btw. trying some tutorials now. so keep it easy please :)
Asked
Active
Viewed 332 times
1 Answers
0
The way I see this, I would notify my clients right after the database operations. So it would look something like this:
db.Save(objectToSave);
var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
context.Clients.All.notifyChange();
In this way, you are able to call clients from outside your hub, so you can have this sort of calls to your clients right after you update the database.
You can also have a look at this tutorial , also this one explains notifications..
If you are familiar with working with databases, keep in mind the approach: just call your clients right after saving in the database.
Hope this helps. Best of luck!

radu-matei
- 3,469
- 1
- 29
- 47
-
Thanks for your help but it throws "synchronous xmlhttprequest on the main thread is deprecated because of its detrimental effects to the end user's experience." :/ – krocheah Aug 27 '15 at 08:50
-
It doesn't have anything to do with SignalR, but with how you make your `ajax` call. [See this SO post](http://stackoverflow.com/questions/27736186/jquery-has-deprecated-synchronous-xmlhttprequest) that answers this concern. But again, it is not a SignalR related issue. Best of luck! – radu-matei Aug 27 '15 at 08:55