2012-07-25 141 views
1

我已经开始在IIS 7上开发.NET 4中的网络聊天。聊天的主页包含2个IFRAME。第一帧用于预留消息并逐步加载(它将消息加载并将消息传递给与聊天连接的所有用户)。第二个iframe用来发送消息。当第一帧加载第二帧不能被加载时,我遇到了一个问题,但如果第一帧停止加载,则以毫秒为单位执行秒。同时加载2个iframe

  1. 我已经尝试过:
  2. 使用AJAX来发送邮件。
  3. 对第一帧和第二帧的脚本使用不同的名称。它有时会帮助但不总是。
  4. 检查用户刷新聊天主页后脚本是否仍然运行或关闭它。
  5. 在IIS中设置连接超时。
  6. 使用流式响应/文本响应。
  7. 连接保持活动/没有保持活动指令。
  8. 交换主聊天页面的Iframe标签。
  9. 以不同的方式添加聊天主页面的CSS JS文件,即@import CSS。
  10. 删除使用。

我发现了一个sollution,但我不认为这是因为使用域访问的JavaScript限制诸多领域很好的解决方案。 iFrames not executing in parallel

这里是Test.aspx文件和Test.aspx.cs页面代码:

<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Test._Default" %> 

using System; 
using System.Web; 
using System.Threading; 

namespace Test 
{ 
    public partial class _Default : System.Web.UI.Page 
    { 
     protected void Page_Load(object sender, EventArgs e) 
     { 
     string p = (Request.QueryString["p"] != null)?Request.QueryString["p"]:""; 
     if(Request.QueryString["data"] == null) 
     { 
      Response.Write(@"<html><head></head><body>12<iframe src=""Test.aspx?data="" height=""900px""></iframe><iframe src=""http://localhost/Test"[email protected]".aspx?data="" height=""900px""></iframe></body></html>"); 
     } 
     else 
     { 
      System.IO.File.AppendAllText(Server.MapPath(".")+ @"\test.log", DateTime.Now.ToString()+ "\t" + "Data script started\r\n"); 
      Response.Write(new String(' ', 1024)); 
      int i=0; 
      while (Response.IsClientConnected) 
      { 
       Response.Write((++i).ToString() + " "); 
       Response.Flush(); 
       Thread.Sleep(1000); 
       System.IO.File.AppendAllText(Server.MapPath(".")+ @"\test.log", DateTime.Now.ToString()+ "\t" + "Data script Runned\r\n"); 

      } 
      System.IO.File.AppendAllText(Server.MapPath(".")+ "test.log", DateTime.Now.ToString()+ "\t" + "Data script stoped\r\n"); 
     } 
    } 
    } 
} 

回答