Как вы думаете, это плохой способ получения уведомлений?Этот WebMethod будет вызываться каждые 10 секунд с помощью JavaScript.Есть ли лучший способ сделать это?Если так, пожалуйста, уточните.Спасибо.
[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;
}