Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET C#-一种实时通知方法_C#_Javascript_Asp.net_Asmx_Webmethod - Fatal编程技术网

ASP.NET C#-一种实时通知方法

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

您认为这是一种检索通知的糟糕方法吗? JavaScript将每10秒调用一次此WebMethod。有没有更好的办法?如果是,请详细说明。多谢各位

[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是最好、最快的解决方案。谢谢