This post may help Asp.Net developers to understand and use Server-sent-Events in their Web Applications. The sample code (provided as download below) demonstrates a simple communication between client(browser) and server, it follows these steps:
You may require to uncomment this line in code:
//Response.Headers.Add("Content-Type", "text/event-stream\n\n");
while working against IIS7 and higher versions of web-server.
Note: use other than IE browsers with HTML5 support.
References:
Download the code files from here.
- Client Initiates the process by opening a connection to server.
- Server pings Client with current Time for every 2second interval for 5 times.
- After 5 times, Client closes the connection with Server.
Above is the screenshot for sample in action (from firefox browser).
You may require to uncomment this line in code:
//Response.Headers.Add("Content-Type", "text/event-stream\n\n");
while working against IIS7 and higher versions of web-server.
Note: use other than IE browsers with HTML5 support.
References:
- https://developer.mozilla.org/en/Server-sent_events/Using_server-sent_events
- http://www.w3.org/TR/2011/WD-eventsource-20110208/
Download the code files from here.
This comment has been removed by a blog administrator.
ReplyDeletewonderful information, I had come to know about your blog from my friend nandu , hyderabad,i have read atleast 7 posts of yours by now, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a ton once again, Regards, Html5 online trainingamong the Html5 in Hyderabad. Classroom Training in Hyderabad India
ReplyDeletePretty interesting post! Thanks it was interesting. into a link
ReplyDeletebrillant piece of information, I had come to know about your web-page from my friend hardkik, chennai,i have read atleast 9 posts of yours by now, and let me tell you, your webpage gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanx a million once again, Regards, obiee training in hyderabad,informatica training in hyderabad
ReplyDelete