Listening to events from Asterisk in ASP.NET (Realtime)

Nov 21, 2013 at 7:53 PM
Hi All!

I was able to create .NET Winforms app to capture the callerID, incoming DID number, etc using AsterNET framework. Thanks to Skrusty!!!
However, when I decided to port the application to ASP.NET I encountered the limitations of web architecture (request-response) when I try to capture the events coming from Asterisk in real time. I can successfully connect to the Asterisk server from my web page, but then I receive a call I cannot capture the event. I figured I would need to use something that can maintain the constant connectivity between server and client.

Has anyone any idea how to listen to events in ASP.NET Webforms application? Has anyone done such thing?
Nov 22, 2013 at 2:50 PM
ASP.NET is different to winforms, as you rightly say, as instances are only 'alive' during the execution of the request. This is OK if you simply want to use the AMI to query some information, but doesn't work well if you want to listen for events.

That being said, if you were listening for events, it's just as hard to then push those events to the client's browser!

One way you might want to look at getting round this would be to implement your AMI code in a console/winforms/service application, and extend out information using something like Self-Hosted WebAPI. This can be very useful, as you can maintain connectivity to the AMI between requests from a browser, but use the WebAPI to service out any information you collect!

Hope this suggestion helps.