473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

ASP.NET Session_OnStart event not firing

35
I am trying to work out an example in ASP.NET
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
  1. <%@ Application Language="C#" %>
  2.  
  3. <script runat="server">
  4.  
  5.     void Application_Start(object sender, EventArgs e) 
  6.     {
  7.         // Code that runs on application startup
  8.         Application["UsersOnline"] = 0;
  9.     }
  10.  
  11.     void Application_End(object sender, EventArgs e) 
  12.     {
  13.         //  Code that runs on application shutdown
  14.  
  15.     }
  16.  
  17.     void Application_Error(object sender, EventArgs e) 
  18.     { 
  19.         // Code that runs when an unhandled error occurs
  20.  
  21.     }
  22.  
  23.     void Session_Start(object sender, EventArgs e) 
  24.     {
  25.         // Code that runs when a new session is started
  26.         Application.Lock();
  27.         Application["UsersOnline"] = (int)Application["UsersOnline"] + 1;
  28.         Application.UnLock();
  29.     }
  30.  
  31.     void Session_End(object sender, EventArgs e) 
  32.     {
  33.         // Code that runs when a session ends. 
  34.         // Note: The Session_End event is raised only when the sessionstate mode
  35.         // is set to InProc in the Web.config file. If session mode is set to StateServer 
  36.      // or SQLServer, the event is not raised.
  37.         Application.Lock();
  38.         Application["UsersOnline"] = (int)Application["UsersOnline"] - 1;
  39.         Application.UnLock();
  40.     }
  41.  
  42. </script>
  43.  
  44.  
Aug 5 '08 #1
2 1652
DrBunchman
979 Expert 512MB
Hi femina

You've posted your question in the ASP Forum which is for Classic ASP only - I've moved it for you but in future please post all ASP.NET questions in the .NET Forum.

Thanks,

Dr B

EDIT: I've just deleted the other post that you made in the .NET Forum - please don't double post your questions, even if you are not sure which forum they are supposed to go in. If you are in any doubt then just say so at the beginning of your post and a Moderator will be happy to move it for you.
Aug 5 '08 #2
Frinavale
9,735 Expert Mod 8TB
Have you tried stepping through your code using a debugger to see what's happening?
Aug 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Steve Mauldin | last post by:
This is a standard ASP application that has several pages at the root withthe global.asa. I set a session variable session("accountid") = "123456" within an asp page and then response.redirect to...
0
by: wannaknow | last post by:
When I set a cookie in global.asa in the sub session_onstart, even if I have "privacy" in IE 6.X set to "block all cookies" the cookie is still set, and I can get it on other pages. I can't find...
0
by: bb | last post by:
Hello In my Session_OnStart in Global.asa, I am setting some cookies. One of them, I set as follows: dim UserID UserID = Request.ServerVariables("LOGON_USER") Response.Cookies("User")("ID")...
31
by: Prabhat | last post by:
Hi All, The "Session_OnStart" event doesnot fire if the website has .htm file as the startup document. If I change the extension of the default document from ..htm to .asp then I can see the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.