最简单方法:
    每个新 Session 产生的时候加一,每个Session 失效的时候减一。然后这个数据记录到全局变量中,一般也就是 Application 上面的方法。 asp  asp.net 都适用。

解决方案 »

  1.   

    see:http://www.kupage.com/webdesign/7/20030223/1458420000007rbyujin.htm
      

  2.   

    每当有一个浏览器启动时,就会产生一个sessionID,记录该sessionID和最后访问时间,存储到application变量里面,并在global.asa里初始化application和把application变量写到数据库里(如果想简便一点,也可以写到文本文件了,在asp里是用fso)
      

  3.   

    也可以考虑用一个静态变量,如static string [] arrManNum;
      

  4.   

    to zhenwang:
    能否说的详细一点?
      

  5.   

    在global.asax.cs文件中:
    using System; 
    using System.Collections; 
    using System.ComponentModel; 
    using System.Web; 
    using System.Web.SessionState; 
    using System.IO ; 
    namespace counter2 

    public class Global : System.Web.HttpApplication 

    protected void Application_Start(Object sender, EventArgs e) 

    uint count=0; 
    StreamReader srd; 
    //取得文件的实际路径 
    string file_path=Server.MapPath ("counter.txt"); 
    //打开文件进行读取 
    srd=File.OpenText (file_path); 
    while(srd.Peek ()!=-1) 

    string str=srd.ReadLine (); 
    count=UInt32.Parse (str); 

    object obj=count; 
    Application["counter"]=obj; 
    srd.Close (); 
    } protected void Session_Start(Object sender, EventArgs e) 

    Application.Lock (); 
    //数值累加,注意这里使用了装箱(boxing) 
    uint jishu=0; 
    jishu=(uint)Application["counter"]; 
    jishu=jishu+1; 
    object obj=jishu; 
    Application["counter"]=obj; 
    //将数据记录写入文件 
    string file_path=Server.MapPath ("counter.txt"); 
    StreamWriter fs=new StreamWriter(file_path,false); 
    fs.WriteLine (jishu); 
    fs.Close (); 
    Application.UnLock (); 

    protected void Application_BeginRequest(Object sender, EventArgs e) 


    protected void Application_EndRequest(Object sender, EventArgs e) 


    protected void Session_End(Object sender, EventArgs e) 


    protected void Application_End(Object sender, EventArgs e) 

    //装箱 
    uint js=0; 
    js=(uint)Application["counter"]; 
    //object obj=js; 
    //Application["counter"]=js; 
    //将数据记录写入文件 
    string file_path=Server.MapPath ("counter.txt"); 
    StreamWriter fs=new StreamWriter(file_path,false); 
    fs.WriteLine(js); 
    fs.Close (); 



    //************************************************
    在要显示计数器的页面中加入<%=Application["counter"]%>