Clicking data from the server to the browser via http

In a general chat application, the client browser always polls the server to check for new messages.

// the function to check new messages in server function check(){ // but this question is less about jQuery. $.ajax({ type: "POST", url: "check.aspx", data: "someparam=123", success: function(msg){ // process msg here // CHECK IT AGAIN, but sometimes we need to make delay here check(); } }); } 

Then I read Nicholas Allen’s Blog on Link Support in IIS .

This makes me think whether it is possible to transfer data from my server to the client browser by transmitting chunked HTTP (does that mean streaming, right?) And keep the connection open .

keeping the connection open, on the server I have an idea for something to start to check for new messages. something like this maybe

 while(connectionStillOpen) { // any new message? if( AnyMessage() ) { // send chunked data, can I? SendMessageToBrowser(); // may be we need to make delay here Sleep(forSomeTime); } } 

what is the original idea.

Chat application created in ASP.net. With my less understanding of WCF and the advanced IIS streaming module, I need your advice on implementing this idea.

yea, Impossible is probably the answer. But I need to know why, if it's still not possible.

UPDATE (3 years later):

This is exactly what I was looking for: Microsoft ASP.NET SignalR

+4
source share
5 answers

Yes, it is impossible to transfer data from the server directly to your browser.

But you can check the server for new messages, say, after 3 seconds and update your client interface.

You might want to take a look at some of the comet implants.

+2
source

The server cannot initiate communication with the client. Therefore, the server cannot transmit data to the client. But you can achieve the push mechanism with "Reverse AJAX". The following article should shed more light.

Reverse AJAX

+2
source

There is one method called reverse AJAX. Using which server can transfer data to the client without any request from the client.

0
source

The current generation of JavaScript / Ajax libraries does not provide access to partial responses; You receive a notification only after the completion of the entire request.

If you are open to using Silverlight, you can use a raw TCP connection.

A comet is another option - but it's basically just a long poll that is still happening on the client side of the script.

0
source

Unable to push data from server. Because HTTP only responds to requests and cannot communicate directly with the client. But we have a workaround called COMET or ReverseAJAX, using this technique, we can simulate duplex calls.

This is nothing but a long live AJAX ringing and will respond to the client if an expected event occurs on the server side, otherwise it stays calm. This comet (programming) Wikipedia article explains more approach

I have a answerd similar question here asp-net-chat-with-wcf . Pls check

0
source

All Articles