i have problem with the session_onstart in the global.asax file
the "UsersOnline" doesnt get updated when i request the webpage again(if iam wrong) or in another browser please help me with the reason and let me have a clear idea on when exactly my session_onstart() will happen
my sample code follows
Expand|Select|Wrap|Line Numbers
- <%@ Application Language="C#" %>
- <script runat="server">
- void Application_Start(object sender, EventArgs e)
- {
- // Code that runs on application startup
- Application["UsersOnline"] = 0;
- }
- void Application_End(object sender, EventArgs e)
- {
- // Code that runs on application shutdown
- }
- void Application_Error(object sender, EventArgs e)
- {
- // Code that runs when an unhandled error occurs
- }
- void Session_Start(object sender, EventArgs e)
- {
- // Code that runs when a new session is started
- Application.Lock();
- Application["UsersOnline"] = (int)Application["UsersOnline"] + 1;
- Application.UnLock();
- }
- void Session_End(object sender, EventArgs e)
- {
- // Code that runs when a session ends.
- // Note: The Session_End event is raised only when the sessionstate mode
- // is set to InProc in the Web.config file. If session mode is set to StateServer
- // or SQLServer, the event is not raised.
- Application.Lock();
- Application["UsersOnline"] = (int)Application["UsersOnline"] - 1;
- Application.UnLock();
- }
- </script>