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