
<%
@ Application Language
=
"
C#
"
%>


<
script RunAt
=
"
server
"
>


void
Application_Start(
object
sender, EventArgs e)


...
{

// 在应用程序启动时运行的代码

Application["user_sessions"] = 0;


}


void
Application_End(
object
sender, EventArgs e)


...
{

// 在应用程序关闭时运行的代码


}


void
Application_Error(
object
sender, EventArgs e)


...
{

// 在出现未处理的错误时运行的代码


}


void
Session_Start(
object
sender, EventArgs e)


...
{

//this.Session.Timeout = 20;

// 在新会话启动时运行的代码

if (this.Session.IsNewSession == true)


...{

Application.Lock();

Application["user_sessions"] = (int)Application["user_sessions"] + 1;

Application.UnLock();

}

}


void
Session_End(
object
sender, EventArgs e)


...
{

// 在会话结束时运行的代码。

// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为

// InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer

// 或 sqlServer,则不会引发该事件。

Application.Lock();

Application["user_sessions"] = (int)Application["user_sessions"] - 1;

Application.UnLock();

}


</
script
>


版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。