locked
Is it possible to send Notification from Web API to Web Forms? RRS feed

  • Question

  • User992810919 posted

    My application is Web Forms Application, where everything is a Web API call. Now I have a typical server to client notification requirement.

    My web api will receive a call, like Stop/Start, which has to notify UI to perform action.

    Is it possible?

    Wednesday, March 1, 2017 7:21 AM

Answers

  • User753101303 posted

    Blocking UI elements in real time based on messages ??? The big picture might help. For example you are not trying to replace optimistic locking ?

    So my understanding is that you have a web api site which is separate from the web forms site where SignalR is sitting and so you'll need some way to transmit this message between the web api and the web forms site.

    If I have control on both sites in my own company my first move would be liekly to write those messages to a db and have SignalR to look for this db using for example https://www.codeproject.com/articles/883702/real-time-notifications-using-signalr-and-sql-depe to at least have something up and running quite quickly and see if the overall concept works fine.

    Then you should always be able to replace just this part with something else if overall architecture is in place. The critical part is likely more to carefully weight if locking a UI in real time does worth.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 3, 2017 9:32 AM

All replies

  • User-1509636757 posted

    How are you calling Web API? Are you using jQuery Ajax to call? Also how/when do you want to show notification? Is it immediately after calling Web API?

    Wednesday, March 1, 2017 11:10 AM
  • User753101303 posted

    Hi,

    You could use web api to "post" a notification message to a queue. The web app would take notifications from this queue (either on the next UI refresh or by polling or using SignalR depending on the feature and how much work you can put into it).

    Wednesday, March 1, 2017 11:21 AM
  • User992810919 posted

    I am using Angular to make AJAX calls. Yeah, I would want to show real time notifications. Basically, I need to block some UI elements with some message.
    The area I am facing Issue is to transfer the message from Web API to Asp.net Web Forms Web Server (where my SignalR is sitting).

    Thursday, March 2, 2017 5:49 AM
  • User992810919 posted

    The web app would take notifications from this queue (either on the next UI refresh or by polling or using SignalR depending on the feature

    How would the web app take notifications from Queue using SignalR?
    I know of this approach where I can WAITFOR message to be dropped in the Queue but does not want to go that way.

    Thursday, March 2, 2017 5:53 AM
  • User1771544211 posted

    Hi Rajesh,

    You can start SignalR from the following link.

    https://docs.microsoft.com/en-us/aspnet/signalr/

    Best Regards,

    Jean

    Friday, March 3, 2017 9:14 AM
  • User753101303 posted

    Blocking UI elements in real time based on messages ??? The big picture might help. For example you are not trying to replace optimistic locking ?

    So my understanding is that you have a web api site which is separate from the web forms site where SignalR is sitting and so you'll need some way to transmit this message between the web api and the web forms site.

    If I have control on both sites in my own company my first move would be liekly to write those messages to a db and have SignalR to look for this db using for example https://www.codeproject.com/articles/883702/real-time-notifications-using-signalr-and-sql-depe to at least have something up and running quite quickly and see if the overall concept works fine.

    Then you should always be able to replace just this part with something else if overall architecture is in place. The critical part is likely more to carefully weight if locking a UI in real time does worth.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 3, 2017 9:32 AM
  • User992810919 posted

    Blocking in UI means a notification only. Basically, there are different web applications which lets say Start and Stop a job. And there is a app say T which has to be notified if there is a job Start from any of other applications. Then the UI notification comes in saying ex "Job Started from app x or y". This all is user specific.
    Past few days, I have been looking for approaches. This same approach is what suits my thing. SQL dependecy + SignalR. 

    Only thing left for me think is about Load Balancing. Each time user logs in I need to store data like userid, connectionId, webappName, etc..

    I know about SQL BackPlane. But wondering the above mentioned data will be in one of the servers, it wont persist after app pool recycle. If I could save this somehow in SQL BackPlane itself, it would be great.

    Any way I can do that? I can explain in more detail. Let me know.

    Friday, March 3, 2017 10:23 AM