2012-12-26 126 views
2

我开发了一个简单的Web应用程序,使用SignalR只是想知道如何使用它。 I类使用::SignalR花费很长时间在铬上执行

public class HealthCheck : Hub 
{ 
    public static List<string> messages = new List<string>(); 
    public void GetServiceState() 
    { 
     Clients.updateMessages(messages); 
    } 
    public void UpdateServiceState() 
    { 
     messages.Add(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));    
     Clients.updateMessages(messages); 
    } 
} 

然后网页我用::

<script type="text/javascript"> 
    $(function() { 
     // creates a proxy to the health check hub 
     var healthCheckHub = $.connection.healthCheck; 
     // handles the callback sent from the server 
     healthCheckHub.updateMessages = function (data) {     
      $("li").remove(); 
      $.each(data, function() { 
       $('#messages').append('<li>' + this + '</li>'); 
      }); 
     }; 
     $("#trigger").click(function() { 
      healthCheckHub.updateServiceState(); 
     }); 
     // Start the connection and request current state 
     $.connection.hub.start(function() { 
      healthCheckHub.getServiceState(); 
     }); 
    }); 
</script> 
<ul id="messages"> 
</ul> 
<button type="button" id="trigger"> 
    Send request</button> 

所有我的问题是,当我点击按钮,它需要很长的时间约40秒或1分钟以便我看到结果...我在FF或IE9上看到结果...

我得到的结果如此之快。

所以这是我的代码或signalR或浏览器中的问题。我正在使用SignalR V 0.5.3

感谢您的帮助。

回答

3

终于让我找到了问题...

我对铬问题的根源是因为我杀毒。

我使用的是AVG互联网安全2013.我需要做的就是禁用'Online Shield'。

了解详情我在这里找到了解决方案:: Connect Pending in Chrome