Demo.html
<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title></title>
<script>
var evt = null
function btnStart_click() {
if (typeof (EventSource) == “undefined”) {
alert(“Server Sent Event not is supported”);
return;
}
evt = new EventSource(“Demo.aspx”);
evt.onmessage = function (event)
{
document.getElementById(“msg”).innerHTML += event.data;
}
}
</script>
</head>
<body>
<div id=”msg”></div>
<hr />
<input type=”button” name=”btnStart” value=”Start” onclick=”btnStart_click()” />
</body>
</html>
Demo.aspx
<%@ Page Language=”C#” AutoEventWireup=”true” %>
<%
Response.ContentType = “text/event-stream”;
Response.Expires = -1;
%>
retry: 1000
data: Demo at <%= DateTime.Now.ToLongTimeString() %><br />