application用法

void Application_Start(object sender, EventArgs e)
{
Application.Lock();
Application["count"] = 0;
Application.UnLock();
}

void Session_Start(object sender, EventArgs e)
{
int count = Convert.ToInt32(Application["count"]);
count++;
Application["count"] = count;

}

void Session_End(object sender, EventArgs e) 
{
    // 在会话结束时运行的代码。 
    // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
    // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
    // 或 SQLServer,则不引发该事件。
    int count = Convert.ToInt32(Application["count"]);
    count--;
    Application["count"] = count;
}

posted on 2015-01-26 14:43  木屐  阅读(181)  评论(0编辑  收藏  举报

导航