use*_*620 0 javascript c# asp.net asmx webmethod
你认为这是一种检索通知的坏方法吗?这个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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2203 次 |
| 最近记录: |