惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

博客园 - Jwin

【转】最近ASP.NET WAP开发的一些情况 showModelessDialog()使用详解 showModalDialog和showModelessDialog的使用【转】 招聘兼职项目开发,寻找长期合作伙伴 转载:动态调用WebService(C#) 数据库优化不能不知道的工具:Database Engine Tuning Advisor【原创】 WebService传多个参数和返回多个参数的方法【转】 如何把文件上传到另外一台服务器【转】 memcached 介绍 项目兼职:SQL Server数据库优化(价格面议) 做网站的人必须遵守的N大定律 ajax 脚本错误 'sys'未定义 (高价)项目兼职:开发qq机器人 关于博客园程序主页模板改进的若干建议 修改UrlRewrite以对域名进行重写,即实现二级或多级域名 【转】 对于URL重写,支持无后缀url请求【转】 转:分布式缓存系统Memcached简介与实践 ASP.NET 2.0的页面缓存功能介绍 [转] Awstats 安装使用说明(转)
asp.net实现显示在线会员
Jwin · 2008-08-17 · via 博客园 - Jwin

asp.net中:
global.asax.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;

namespace alumniV2
{
 /// <summary>
 /// Global 的摘要说明。
 /// </summary>
 public class Global : System.Web.HttpApplication
 {
  public Global()
  {
   InitializeComponent();
  } 
  
  protected void Application_Start(Object sender, EventArgs e)
  {
   Application.Lock ();
   
   Application["usernum"]=0;
   Application["onlineuser"]="";   
   Application["guestnum"]=0;

   Application.UnLock ();
  }
 
  protected void Session_Start(Object sender, EventArgs e)
  {
   Application.Lock ();

   Application["guestnum"]=(Int32)Application["guestnum"]+1;

   Application.UnLock ();
  }

  protected void Application_BeginRequest(Object sender, EventArgs e)
  {

  }

  protected void Application_EndRequest(Object sender, EventArgs e)
  {

  }

  protected void Application_AuthenticateRequest(Object sender, EventArgs e)
  {

  }

  protected void Application_Error(Object sender, EventArgs e)
  {

  }

  protected void Session_End(Object sender, EventArgs e)
  {
   Application.Lock ();
   string name;
   if (Request.Cookies ["personal"]!=null )
   {
    name=Request.Cookies ["personal"]["username"] ;
    if (name!="")
    {
      Application["usernum"]=(Int32)Application["usernum"]-1;

      Application["onlineuser"]=(Application["onlineuser"]+"").Replace (name+"$","");

    }
    else
     Application["guestnum"]=(Int32)Application["guestnum"]-1;
   }
   else
    Application["guestnum"]=(Int32)Application["guestnum"]-1;
   Application.UnLock ();
  }

  protected void Application_End(Object sender, EventArgs e)
  {
   Application.Lock ();
   
   Application["usernum"]=0;
   Application["onlineuser"]="";   
   Application["guestnum"]=0;

   Application.UnLock ();
  }
   
  #region Web Form Designer generated code
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
  }
  #endregion
 }
}

index.aspx.cs

  private void ShowOnlineUser()
  {
   onlinenum.Text ="  当前共有 <font color=red>"+ Application["usernum"] +"</font>  个成员 <font color=red>"+ Application["guestnum"] +"</font>  个客人在线   <img src='images/user.gif'> <font color=red>成员</font>   <img src='images/guest.gif'> 客人 ";

   string oluserstr;
   string []oluser;
   int n;
   oluserstr="";
   if (Application["onlineuser"]!=null)
   {
    //oluser1=;
    oluser=(Application["onlineuser"]+"").Split('$');
    for (n=0;oluser[n]!="" && oluser[n]!=null;n++)
     oluserstr=oluserstr+"  <img src='images/user.gif'> <a href='myinfo.aspx?username="+Server.UrlEncode(oluser[n])+"'><font color=red>"+oluser[n]+"</font></a> ";
   }
    
   if (Application["guestnum"]!=null)
   {
    for (n=0;n<(Int32)Application["guestnum"];n++)
     oluserstr=oluserstr+"  <img src='images/guest.gif'> 客人 ";
   }
   onlineuser.Text =oluserstr;
  }