ASP.NET C#-一种实时通知方法
您认为这是一种检索通知的糟糕方法吗? JavaScript将每10秒调用一次此WebMethod。有没有更好的办法?如果是,请详细说明。多谢各位ASP.NET C#-一种实时通知方法,c#,javascript,asp.net,asmx,webmethod,C#,Javascript,Asp.net,Asmx,Webmethod,您认为这是一种检索通知的糟糕方法吗? JavaScript将每10秒调用一次此WebMethod。有没有更好的办法?如果是,请详细说明。多谢各位 [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public int[] GetNotifications() { int[] Notifications = new int[3]{0, 0, 0}; if (HttpContext.Current.Use
[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;
}
查看ASP.NET的异步信号库。查看ASP.NET的异步信号库。查看Comet或reverse AJAX。查看Comet或reverse AJAX。您能看一下吗?SignalR是最好、最快的解决方案。谢谢。你能看看这个吗?SignalR是最好、最快的解决方案。谢谢