2011-11-14 1 views
0

알림을 검색하는 것이 좋지 않다고 생각하십니까? 이 WebMethod는 JavaScript로 10 초마다 호출됩니다. 이 작업을 수행하는 더 좋은 방법이 있습니까? 그렇다면 정교하게하십시오. 고맙습니다.ASP.NET C# - 실시간 알림 방법

[WebMethod] 
[ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
public int[] GetNotifications() 
{ 
    int[] Notifications = new int[3]{0, 0, 0}; 
    if (HttpContext.Current.User.Identity.IsAuthenticated) { 
     string UserName = HttpContext.Current.User.Identity.Name; 
     Notifications[0] = Notification.GetAll(UserName, false).Count; 
     Notifications[1] = Message.GetAll(UserName, false).Count; 
     Notifications[2] = Friendship.GetFriends(UserName, true).Count; 
    } 
    return Notifications; 
} 
+3

혜성을 들여다 보거나 AJAX를 뒤집습니다. – SLaks

답변

6

ASP.NET에 대한 SignalR 비동기 신호 라이브러리를 확인하십시오.

+0

제발 이것 좀 봐 주실 래요? http://stackoverflow.com/questions/8119103/signalr-refuses-to-work – user1027620

+0

SignalR은 가장 빠르고 가장 빠른 솔루션입니다. 감사. – user1027620