18

What's the best way to push info from a server to a web client? I know it's possible to setup sockets with Silverlight and Flash but I want to stay way from those two technologies.

Gmail seems to do a great job of polling the servers for updated emails and even their chat programs work great (all working in my web browser). Any ideas on the best way to do something like this but using asp.net?

Edit: If I have to poll, i'd like to poll the server every 2 or 3 seconds. So I'm not sure how to do this without bringing the web server to it's knees under heavy usage.

  • Re: Polling frequency, 2-3 second polling on a very light weight web service is usually more scalable than true HTTP "push" implementations. Holding connections permanently open is resource intensive. – Dave Ward Feb 05 '09 at 16:50
  • Two examples available at http://www.udaparts.com/document/Tutorial/httppush.htm and http://www.udaparts.com/document/Tutorial/slpush.htm –  Sep 03 '11 at 21:49

6 Answers6

7

Since you mention ASP.NET you should be using SignalR. See my other answer here: Instant notifications like Facebook

Community
  • 1
  • 1
Christoph
  • 21,851
  • 24
  • 86
  • 121
  • Has anyone any experience of scaling SignalR? I need to push small messages to 100,000 or so clients (the same message to all of them stock ticker style) how many servers is that going to need? – Martin Brown May 10 '16 at 14:31
5

The push technique you are looking for is called Comet. See this article for some pointers.

D'Arcy Rittich
  • 153,827
  • 35
  • 271
  • 277
4

Try out WebSync, a scalable comet server built for .NET/IIS. It'll let you push data nicely from the server, and integrates super easily with ASP.NET projects (a couple web.config entries is all it takes).

jvenema
  • 42,243
  • 5
  • 64
  • 107
4

PokeIn is a reverse ajax library for ASP.NET & Mono. It has various capabilities like .NET to JSON vice versa. You may download sample projects from here

Zuuum
  • 1,505
  • 11
  • 18
4

I would create a script callable Web Service and use JQuery.

Here's a good guide on using JQuery to call an ASP.NET (ASMX) web service:

http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

Now, you would just poll this web service at whatever interval makes sense for your application.

Also, the problem with ASP.NET AJAX is it's a bit top heavy. By using JQuery, you can call your web service from a regular ASP.NET web form, from a View in MVC, or actually using any other web technology (classic ASP, PHP, whatever) all from the client side using just, in my view, the best javascript framework around. :)

BobbyShaftoe
  • 27,660
  • 5
  • 50
  • 71
0

To do that, use ASP.NET 3.0/3.5 or if you are using earlier versions, use ASP.NET Ajax. However both examples listed by you, are using Ajax to pull information, not push it.

Ilya Volodin
  • 9,648
  • 2
  • 39
  • 45