Web API Event Notification

I need clients (C # applications) of the ASP.NET web API to be notified of some changes through the web API. They don’t even need to know what the changes are, they just need to get a notification that something has changed (at this moment, the client needs to call the API to get any specific data that they may need after receiving the notification). I'm not sure what a good way to accomplish this would look.

I think that one of the ways could be to create events and somehow the client subscribed to these events, but I do not know how to do this using the web API.

I found a few mentions of SignalR on Google, but this seems like a lot of implementation work and seems to do a lot more than I need.

All I need is for the web API to tell the client "something has changed, come and get." However, I want to avoid the survey. What is the fastest / easiest way to do this?

+4
source share
3 answers

You really only have two options:

  • Use SignalR or any Websocket infrastructure.
  • Ask client applications to query the API for changes.

The web interface by default has no analogues. The API does not support any connection or status information with any of the client applications. Therefore, there is no way to implement something like a traditional C # event.

+7
source

SignalR ;)

- X : "- ?".

+5

After 3 years .. and there is another option that looks very promising, which WebHooks

  • Poll
  • SignalR (Server ↔ Server, Server ↔ Browser)
  • WebHooks (Server ↔ Server)

The difference between SignalR and WebHooks

0
source

All Articles