-1

i'm currently looking for an sample code regarding the comet implementation or Reverse Ajax of sending data from server to client im currently using MVC application back-end code is c# and java script as my script / Jquery Can you provide a simple sample regarding this matter? i just need to send a data on the server which will receive in client side.

bRaNdOn
  • 1,060
  • 4
  • 17
  • 37

2 Answers2

1

You can use SignalR to achieve this functionality and it's doing an even better job that what you are trying to do, because it attempts to use Websockets first.

SignalR

HTML 5 transports

These transports depend on support for HTML 5. If the client browser does not support the HTML 5 standard, older transports will be used.

WebSocket (if the both the server and browser indicate they can support Websocket). WebSocket is the only transport that establishes a true persistent, two-way connection between client and server. However, WebSocket also has the most stringent requirements; it is fully supported only in the latest versions of Microsoft Internet Explorer, Google Chrome, and Mozilla Firefox, and only has a partial implementation in other browsers such as Opera and Safari. Server Sent Events, also known as EventSource (if the browser supports Server Sent Events, which is basically all browsers except Internet Explorer.) Comet transports

The following transports are based on the Comet web application model, in which a browser or other client maintains a long-held HTTP request, which the server can use to push data to the client without the client specifically requesting it.

Forever Frame (for Internet Explorer only). Forever Frame creates a hidden IFrame which makes a request to an endpoint on the server that does not complete. The server then continually sends script to the client which is immediately executed, providing a one-way realtime connection from server to client. The connection from client to server uses a separate connection from the server to client connection, and like a standard HTML request, a new connection is created for each piece of data that needs to be sent. Ajax long polling. Long polling does not create a persistent connection, but instead polls the server with a request that stays open until the server responds, at which point the connection closes, and a new connection is requested immediately. This may introduce some latency while the connection resets.

Lee Gary
  • 2,357
  • 2
  • 22
  • 38
1

You can check these:
Top 20 NuGet packages for Comet http://nugetmusthaves.com/Tag/Comet
Comet implementation for ASP.NET?
https://pokein.codeplex.com/
Creating Comet applications with ASP.NET http://www.aaronlerch.com/blog/2007/07/08/creating-comet-applications-with-aspnet/
and a lot more by googling.

Community
  • 1
  • 1
Amr Elgarhy
  • 66,568
  • 69
  • 184
  • 301
  • Hi i have tried the last link that you gave me is it possible to return a json data in that approach i tried but its now working? – bRaNdOn Oct 09 '14 at 08:46