如何使用ASP.NET开发基于推技术的聊天室?
public class Content : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
Session.Timeout = 60;
Response.Write("欢迎 . . .<br> ");
Response.Flush();
Application[Session.SessionID] = Response;
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
}
}
// Send.aspx.cs //////////////////////////////////////////////////////////
public class Send : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button ButtonSend;
protected System.Web.UI.WebControls.TextBox TextBox1;
private void ButtonSend_Click(object sender, System.EventArgs e)
{
foreach(string name in Application.AllKeys)
{
HttpResponse Response = Application[name] as HttpResponse;
if(Response!=null && Response.IsClientConnected)
{
Response.Write(TextBox1.Text + "<br> ");
Response.Flush();
}
else
{
Application.Remove(name);
}
}
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。