Session_End never fires

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Session_End never fires

    I've got an ASP.NET page with a counter subtraction routine in the
    Session_End method in the Global.asax.cs:

    protected void Session_End(Object sender, EventArgs e)

    {

    ulong curUsers;

    Application.Lock();

    curUsers = (ulong)Application["curUsers"];

    curUsers--;

    Application["iCurUsers"] = curUsers;

    Application.UnLock();

    }

    Basically, this is supposed to keep track of the number of users that are
    logged into the system by keeping track of the number of open sessions --
    except that the Session_End NEVER fires. I've checked my web.config file
    and it does show the mode as InProc:

    <sessionState

    mode="InProc"

    stateConnectionString="tcpip=127.0.0.1:42424"

    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

    cookieless="false"

    timeout="20"

    />

    Is there something else I missed??


    Kenn Ghannon Guest

  2. Similar Questions and Discussions

    1. OnItemCreated fires twice
      All, On the initial load of my grid, the OnItemCreated event fires once. However, when any other grid event fires - sorting, paging - the...
    2. TextBox init never fires???
      Put TextBox on webform. Select Init between it's events and create eventhandler It seems to me that this event has never fired, why? Thanks
    3. Session lasting too long -- Session_End event firing way late !! ??
      Why are my sessions lasting so long? I have them set to 20 minute timeout in config file? The Session_End event is getting called an hour or more...
    4. session_end and re-login
      Dear ASP.NET Programmers, I am using forms authentication in my web application. I would like the users to be transferred to the login page when...
    5. Session_End Not Firing
      Hey guys I have a user tracking setup to track users. What it does is once a user hits my site it sends me an email telling me some info and once a...
  3. #2

    Default Re: Session_End never fires

    How do you know for sure that it NEVER fires? The Session_End Event happens
    usually some time after the user has closed their browser or navigated
    elsewhere. As the server has no idea what is happening on the client, the
    Session ends 20 (by default, and according to your web.config file) minutes
    after the last Request from that user. So, again, are you sure it is NEVER
    firing?

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    [url]http://www.takempis.com[/url]
    Some things just happen.
    Everything else occurs.

    "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > I've got an ASP.NET page with a counter subtraction routine in the
    > Session_End method in the Global.asax.cs:
    >
    > protected void Session_End(Object sender, EventArgs e)
    >
    > {
    >
    > ulong curUsers;
    >
    > Application.Lock();
    >
    > curUsers = (ulong)Application["curUsers"];
    >
    > curUsers--;
    >
    > Application["iCurUsers"] = curUsers;
    >
    > Application.UnLock();
    >
    > }
    >
    > Basically, this is supposed to keep track of the number of users that are
    > logged into the system by keeping track of the number of open sessions --
    > except that the Session_End NEVER fires. I've checked my web.config file
    > and it does show the mode as InProc:
    >
    > <sessionState
    >
    > mode="InProc"
    >
    > stateConnectionString="tcpip=127.0.0.1:42424"
    >
    > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    >
    > cookieless="false"
    >
    > timeout="20"
    >
    > />
    >
    > Is there something else I missed??
    >
    >

    Kevin Spencer Guest

  4. #3

    Default Re: Session_End never fires

    I print the value of the curUsers counter (along with another one that is
    supposed to keep track of the number of users that have ever visited the
    site) on the home page. The values of these two counters are ALWAYS equal
    and get reset at the same time (I've had both counters up to over 2000
    before the application ended and each counter was reset to 0...because I
    have a Application_End() routine that is supposed to save the counter to a
    file -- and an accompanying Application_Start() routine to read it in so
    that when the application starts again, I can start counting where I left
    off -- but never seems to fire either. The counter file is always set to
    0).


    "Kevin Spencer" <kevin@SPAMMERSSUCKtakempis.com> wrote in message
    news:#AmQjBWRDHA.2480@tk2msftngp13.phx.gbl...
    > How do you know for sure that it NEVER fires? The Session_End Event
    happens
    > usually some time after the user has closed their browser or navigated
    > elsewhere. As the server has no idea what is happening on the client, the
    > Session ends 20 (by default, and according to your web.config file)
    minutes
    > after the last Request from that user. So, again, are you sure it is NEVER
    > firing?
    >
    > HTH,
    >
    > Kevin Spencer
    > Microsoft FrontPage MVP
    > Internet Developer
    > [url]http://www.takempis.com[/url]
    > Some things just happen.
    > Everything else occurs.
    >
    > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > > I've got an ASP.NET page with a counter subtraction routine in the
    > > Session_End method in the Global.asax.cs:
    > >
    > > protected void Session_End(Object sender, EventArgs e)
    > >
    > > {
    > >
    > > ulong curUsers;
    > >
    > > Application.Lock();
    > >
    > > curUsers = (ulong)Application["curUsers"];
    > >
    > > curUsers--;
    > >
    > > Application["iCurUsers"] = curUsers;
    > >
    > > Application.UnLock();
    > >
    > > }
    > >
    > > Basically, this is supposed to keep track of the number of users that
    are
    > > logged into the system by keeping track of the number of open
    sessions --
    > > except that the Session_End NEVER fires. I've checked my web.config
    file
    > > and it does show the mode as InProc:
    > >
    > > <sessionState
    > >
    > > mode="InProc"
    > >
    > > stateConnectionString="tcpip=127.0.0.1:42424"
    > >
    > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > >
    > > cookieless="false"
    > >
    > > timeout="20"
    > >
    > > />
    > >
    > > Is there something else I missed??
    > >
    > >
    >
    >

    Kenn Ghannon Guest

  5. #4

    Default Re: Session_End never fires

    look for code logic problems, cause it will fire - i promise!

    also, you can force the event with SESSION.ABANDON method... and place a
    break-point to debug the routine...


    "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    news:p5BOa.6931$Vx2.3206330@newssvr28.news.prodigy .com...
    > I print the value of the curUsers counter (along with another one that is
    > supposed to keep track of the number of users that have ever visited the
    > site) on the home page. The values of these two counters are ALWAYS equal
    > and get reset at the same time (I've had both counters up to over 2000
    > before the application ended and each counter was reset to 0...because I
    > have a Application_End() routine that is supposed to save the counter to a
    > file -- and an accompanying Application_Start() routine to read it in so
    > that when the application starts again, I can start counting where I left
    > off -- but never seems to fire either. The counter file is always set to
    > 0).
    >
    >
    > "Kevin Spencer" <kevin@SPAMMERSSUCKtakempis.com> wrote in message
    > news:#AmQjBWRDHA.2480@tk2msftngp13.phx.gbl...
    > > How do you know for sure that it NEVER fires? The Session_End Event
    > happens
    > > usually some time after the user has closed their browser or navigated
    > > elsewhere. As the server has no idea what is happening on the client,
    the
    > > Session ends 20 (by default, and according to your web.config file)
    > minutes
    > > after the last Request from that user. So, again, are you sure it is
    NEVER
    > > firing?
    > >
    > > HTH,
    > >
    > > Kevin Spencer
    > > Microsoft FrontPage MVP
    > > Internet Developer
    > > [url]http://www.takempis.com[/url]
    > > Some things just happen.
    > > Everything else occurs.
    > >
    > > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > > news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > > > I've got an ASP.NET page with a counter subtraction routine in the
    > > > Session_End method in the Global.asax.cs:
    > > >
    > > > protected void Session_End(Object sender, EventArgs e)
    > > >
    > > > {
    > > >
    > > > ulong curUsers;
    > > >
    > > > Application.Lock();
    > > >
    > > > curUsers = (ulong)Application["curUsers"];
    > > >
    > > > curUsers--;
    > > >
    > > > Application["iCurUsers"] = curUsers;
    > > >
    > > > Application.UnLock();
    > > >
    > > > }
    > > >
    > > > Basically, this is supposed to keep track of the number of users that
    > are
    > > > logged into the system by keeping track of the number of open
    > sessions --
    > > > except that the Session_End NEVER fires. I've checked my web.config
    > file
    > > > and it does show the mode as InProc:
    > > >
    > > > <sessionState
    > > >
    > > > mode="InProc"
    > > >
    > > > stateConnectionString="tcpip=127.0.0.1:42424"
    > > >
    > > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > > >
    > > > cookieless="false"
    > > >
    > > > timeout="20"
    > > >
    > > > />
    > > >
    > > > Is there something else I missed??
    > > >
    > > >
    > >
    > >
    >
    >
    >

    David Waz... Guest

  6. #5

    Default Re: Session_End never fires

    No real error handling...but I've even gone so far as to put a
    Session.Abandon() call in my code-behind file...and it STILL does not end.
    Here're the particulars:

    From my home.aspx.cs file:
    private void Page_Load(object sender, System.EventArgs e)

    {

    orgLog myLog = (orgLog)Application["orgLog"];

    myLog.WriteLine( "Testing" );

    Session.Abandon();

    }

    From my global.asax.cs file:
    protected void Session_Start(Object sender, EventArgs e)

    {

    orgLog LogFile;

    Application.Lock();

    LogFile = (orgLog)Application["orgLog"];

    Application.UnLock();

    Session["IPADDR"] = "19.19.19.19"; // just used to store something in the
    session

    LogFile.WriteLine( ":: Session Begins for " +
    Request.ServerVariables["REMOTE_ADDR"].ToString() );

    }

    protected void Session_End(Object sender, EventArgs e)

    {

    orgLog LogFile;

    Application.Lock();

    LogFile = (orgLog)Application["orgLog"];

    Application.UnLock();

    LogFile.WriteLine( ":: Session Ends for " +
    Request.ServerVariables["REMOTE_ADDR"].ToString() );

    }

    // orgLog is a home made information logging tool (it creates a log file).
    I'd think that maybe the problem is here, but I can log to it over and over
    without difficulty..

    From the Log File:

    [7/9/2003 4:10:37 PM] == Application Starts ==
    [7/9/2003 4:10:38 PM] :: Session Begins for 127.0.0.1
    [7/9/2003 4:10:38 PM] Testing
    [7/9/2003 4:25:25 PM] == Application Starts ==
    [7/9/2003 4:25:25 PM] :: Session Begins for 127.0.0.1
    [7/9/2003 4:25:25 PM] Testing
    [7/9/2003 4:30:27 PM] :: Session Begins for 127.0.0.1
    [7/9/2003 4:30:27 PM] Testing
    [7/9/2003 4:30:28 PM] :: Session Begins for 127.0.0.1
    [7/9/2003 4:30:28 PM] Testing

    Notice that I'm getting a new Session for each iteration (I'm not sure why)
    but I'm never getting a Session_End...

    If anyone notices anything out of place, please let me know. I've got my
    session timeout set to 1, so I should be getting the session_end after a
    minute...but I just seem to be getting a new session without the old session
    ever ending...

    "Kevin Spencer" <kevin@SPAMMERSSUCKtakempis.com> wrote in message
    news:OlV7iaXRDHA.2636@TK2MSFTNGP10.phx.gbl...
    > What sort of error-handling are you implementing for this? It sounds like
    an
    > error may be aborting the process somewhere.
    >
    > HTH,
    >
    > Kevin Spencer
    > Microsoft FrontPage MVP
    > Internet Developer
    > [url]http://www.takempis.com[/url]
    > Some things just happen.
    > Everything else occurs.
    >
    > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > news:p5BOa.6931$Vx2.3206330@newssvr28.news.prodigy .com...
    > > I print the value of the curUsers counter (along with another one that
    is
    > > supposed to keep track of the number of users that have ever visited the
    > > site) on the home page. The values of these two counters are ALWAYS
    equal
    > > and get reset at the same time (I've had both counters up to over 2000
    > > before the application ended and each counter was reset to 0...because I
    > > have a Application_End() routine that is supposed to save the counter to
    a
    > > file -- and an accompanying Application_Start() routine to read it in so
    > > that when the application starts again, I can start counting where I
    left
    > > off -- but never seems to fire either. The counter file is always set
    to
    > > 0).
    > >
    > >
    > > "Kevin Spencer" <kevin@SPAMMERSSUCKtakempis.com> wrote in message
    > > news:#AmQjBWRDHA.2480@tk2msftngp13.phx.gbl...
    > > > How do you know for sure that it NEVER fires? The Session_End Event
    > > happens
    > > > usually some time after the user has closed their browser or navigated
    > > > elsewhere. As the server has no idea what is happening on the client,
    > the
    > > > Session ends 20 (by default, and according to your web.config file)
    > > minutes
    > > > after the last Request from that user. So, again, are you sure it is
    > NEVER
    > > > firing?
    > > >
    > > > HTH,
    > > >
    > > > Kevin Spencer
    > > > Microsoft FrontPage MVP
    > > > Internet Developer
    > > > [url]http://www.takempis.com[/url]
    > > > Some things just happen.
    > > > Everything else occurs.
    > > >
    > > > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > > > news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > > > > I've got an ASP.NET page with a counter subtraction routine in the
    > > > > Session_End method in the Global.asax.cs:
    > > > >
    > > > > protected void Session_End(Object sender, EventArgs e)
    > > > >
    > > > > {
    > > > >
    > > > > ulong curUsers;
    > > > >
    > > > > Application.Lock();
    > > > >
    > > > > curUsers = (ulong)Application["curUsers"];
    > > > >
    > > > > curUsers--;
    > > > >
    > > > > Application["iCurUsers"] = curUsers;
    > > > >
    > > > > Application.UnLock();
    > > > >
    > > > > }
    > > > >
    > > > > Basically, this is supposed to keep track of the number of users
    that
    > > are
    > > > > logged into the system by keeping track of the number of open
    > > sessions --
    > > > > except that the Session_End NEVER fires. I've checked my web.config
    > > file
    > > > > and it does show the mode as InProc:
    > > > >
    > > > > <sessionState
    > > > >
    > > > > mode="InProc"
    > > > >
    > > > > stateConnectionString="tcpip=127.0.0.1:42424"
    > > > >
    > > > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > > > >
    > > > > cookieless="false"
    > > > >
    > > > > timeout="20"
    > > > >
    > > > > />
    > > > >
    > > > > Is there something else I missed??
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Kenn Ghannon Guest

  7. #6

    Default Re: Session_End never fires

    Actually, I DO know why...the added Session.Abandon()...but it still never
    goes to Session_End...


    "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    news:x__Oa.7206$Vx2.3444725@newssvr28.news.prodigy .com...
    > No real error handling...but I've even gone so far as to put a
    > Session.Abandon() call in my code-behind file...and it STILL does not end.
    > Here're the particulars:
    >
    > From my home.aspx.cs file:
    > private void Page_Load(object sender, System.EventArgs e)
    >
    > {
    >
    > orgLog myLog = (orgLog)Application["orgLog"];
    >
    > myLog.WriteLine( "Testing" );
    >
    > Session.Abandon();
    >
    > }
    >
    > From my global.asax.cs file:
    > protected void Session_Start(Object sender, EventArgs e)
    >
    > {
    >
    > orgLog LogFile;
    >
    > Application.Lock();
    >
    > LogFile = (orgLog)Application["orgLog"];
    >
    > Application.UnLock();
    >
    > Session["IPADDR"] = "19.19.19.19"; // just used to store something in the
    > session
    >
    > LogFile.WriteLine( ":: Session Begins for " +
    > Request.ServerVariables["REMOTE_ADDR"].ToString() );
    >
    > }
    >
    > protected void Session_End(Object sender, EventArgs e)
    >
    > {
    >
    > orgLog LogFile;
    >
    > Application.Lock();
    >
    > LogFile = (orgLog)Application["orgLog"];
    >
    > Application.UnLock();
    >
    > LogFile.WriteLine( ":: Session Ends for " +
    > Request.ServerVariables["REMOTE_ADDR"].ToString() );
    >
    > }
    >
    > // orgLog is a home made information logging tool (it creates a log file).
    > I'd think that maybe the problem is here, but I can log to it over and
    over
    > without difficulty..
    >
    > From the Log File:
    >
    > [7/9/2003 4:10:37 PM] == Application Starts ==
    > [7/9/2003 4:10:38 PM] :: Session Begins for 127.0.0.1
    > [7/9/2003 4:10:38 PM] Testing
    > [7/9/2003 4:25:25 PM] == Application Starts ==
    > [7/9/2003 4:25:25 PM] :: Session Begins for 127.0.0.1
    > [7/9/2003 4:25:25 PM] Testing
    > [7/9/2003 4:30:27 PM] :: Session Begins for 127.0.0.1
    > [7/9/2003 4:30:27 PM] Testing
    > [7/9/2003 4:30:28 PM] :: Session Begins for 127.0.0.1
    > [7/9/2003 4:30:28 PM] Testing
    >
    > Notice that I'm getting a new Session for each iteration (I'm not sure
    why)
    > but I'm never getting a Session_End...
    >
    > If anyone notices anything out of place, please let me know. I've got my
    > session timeout set to 1, so I should be getting the session_end after a
    > minute...but I just seem to be getting a new session without the old
    session
    > ever ending...
    >
    > "Kevin Spencer" <kevin@SPAMMERSSUCKtakempis.com> wrote in message
    > news:OlV7iaXRDHA.2636@TK2MSFTNGP10.phx.gbl...
    > > What sort of error-handling are you implementing for this? It sounds
    like
    > an
    > > error may be aborting the process somewhere.
    > >
    > > HTH,
    > >
    > > Kevin Spencer
    > > Microsoft FrontPage MVP
    > > Internet Developer
    > > [url]http://www.takempis.com[/url]
    > > Some things just happen.
    > > Everything else occurs.
    > >
    > > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > > news:p5BOa.6931$Vx2.3206330@newssvr28.news.prodigy .com...
    > > > I print the value of the curUsers counter (along with another one that
    > is
    > > > supposed to keep track of the number of users that have ever visited
    the
    > > > site) on the home page. The values of these two counters are ALWAYS
    > equal
    > > > and get reset at the same time (I've had both counters up to over 2000
    > > > before the application ended and each counter was reset to 0...because
    I
    > > > have a Application_End() routine that is supposed to save the counter
    to
    > a
    > > > file -- and an accompanying Application_Start() routine to read it in
    so
    > > > that when the application starts again, I can start counting where I
    > left
    > > > off -- but never seems to fire either. The counter file is always set
    > to
    > > > 0).
    > > >
    > > >
    > > > "Kevin Spencer" <kevin@SPAMMERSSUCKtakempis.com> wrote in message
    > > > news:#AmQjBWRDHA.2480@tk2msftngp13.phx.gbl...
    > > > > How do you know for sure that it NEVER fires? The Session_End Event
    > > > happens
    > > > > usually some time after the user has closed their browser or
    navigated
    > > > > elsewhere. As the server has no idea what is happening on the
    client,
    > > the
    > > > > Session ends 20 (by default, and according to your web.config file)
    > > > minutes
    > > > > after the last Request from that user. So, again, are you sure it is
    > > NEVER
    > > > > firing?
    > > > >
    > > > > HTH,
    > > > >
    > > > > Kevin Spencer
    > > > > Microsoft FrontPage MVP
    > > > > Internet Developer
    > > > > [url]http://www.takempis.com[/url]
    > > > > Some things just happen.
    > > > > Everything else occurs.
    > > > >
    > > > > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > > > > news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > > > > > I've got an ASP.NET page with a counter subtraction routine in the
    > > > > > Session_End method in the Global.asax.cs:
    > > > > >
    > > > > > protected void Session_End(Object sender, EventArgs e)
    > > > > >
    > > > > > {
    > > > > >
    > > > > > ulong curUsers;
    > > > > >
    > > > > > Application.Lock();
    > > > > >
    > > > > > curUsers = (ulong)Application["curUsers"];
    > > > > >
    > > > > > curUsers--;
    > > > > >
    > > > > > Application["iCurUsers"] = curUsers;
    > > > > >
    > > > > > Application.UnLock();
    > > > > >
    > > > > > }
    > > > > >
    > > > > > Basically, this is supposed to keep track of the number of users
    > that
    > > > are
    > > > > > logged into the system by keeping track of the number of open
    > > > sessions --
    > > > > > except that the Session_End NEVER fires. I've checked my
    web.config
    > > > file
    > > > > > and it does show the mode as InProc:
    > > > > >
    > > > > > <sessionState
    > > > > >
    > > > > > mode="InProc"
    > > > > >
    > > > > > stateConnectionString="tcpip=127.0.0.1:42424"
    > > > > >
    > > > > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > > > > >
    > > > > > cookieless="false"
    > > > > >
    > > > > > timeout="20"
    > > > > >
    > > > > > />
    > > > > >
    > > > > > Is there something else I missed??
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Kenn Ghannon Guest

  8. #7

    Default Re: Session_End never fires

    Of course the Request object is invalid on Session_End! The Session ends
    AFTER the last Request has been processed!

    --
    HTH,

    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    [url]http://www.takempis.com[/url]
    Big things are made up
    of lots of little things

    "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    news:Wa0Pa.7212$Vx2.3453809@newssvr28.news.prodigy .com...
    > Please excuse me for being a freaking newbie. :) I didn't know that you
    > could debug the global.asax.cs file...
    >
    > Turns out that the Request object is no longer valid during Session_End
    (It
    > says there's an HTML Exception when doing a 'Watch' of the Request
    object --
    > but I'm not doing anything weird and I've walked it until the session
    timed
    > out -- and the Request object was valid when the page rendered and wasn't
    > when it came back to Session_End...
    >
    > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > > I've got an ASP.NET page with a counter subtraction routine in the
    > > Session_End method in the Global.asax.cs:
    > >
    > > protected void Session_End(Object sender, EventArgs e)
    > >
    > > {
    > >
    > > ulong curUsers;
    > >
    > > Application.Lock();
    > >
    > > curUsers = (ulong)Application["curUsers"];
    > >
    > > curUsers--;
    > >
    > > Application["iCurUsers"] = curUsers;
    > >
    > > Application.UnLock();
    > >
    > > }
    > >
    > > Basically, this is supposed to keep track of the number of users that
    are
    > > logged into the system by keeping track of the number of open
    sessions --
    > > except that the Session_End NEVER fires. I've checked my web.config
    file
    > > and it does show the mode as InProc:
    > >
    > > <sessionState
    > >
    > > mode="InProc"
    > >
    > > stateConnectionString="tcpip=127.0.0.1:42424"
    > >
    > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > >
    > > cookieless="false"
    > >
    > > timeout="20"
    > >
    > > />
    > >
    > > Is there something else I missed??
    > >
    > >
    >
    >

    Kevin Spencer Guest

  9. #8

    Default Re: Session_End never fires

    BTW, using some try/catch blocks in your code would have helped you debug a
    good bit. For example, you could have the app write an Event Log entry with
    a Stack Trace and the error details when an error occurs. That way you would
    know exactly where any error occurs.

    --
    HTH,

    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    [url]http://www.takempis.com[/url]
    Big things are made up
    of lots of little things

    "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    news:Wa0Pa.7212$Vx2.3453809@newssvr28.news.prodigy .com...
    > Please excuse me for being a freaking newbie. :) I didn't know that you
    > could debug the global.asax.cs file...
    >
    > Turns out that the Request object is no longer valid during Session_End
    (It
    > says there's an HTML Exception when doing a 'Watch' of the Request
    object --
    > but I'm not doing anything weird and I've walked it until the session
    timed
    > out -- and the Request object was valid when the page rendered and wasn't
    > when it came back to Session_End...
    >
    > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > > I've got an ASP.NET page with a counter subtraction routine in the
    > > Session_End method in the Global.asax.cs:
    > >
    > > protected void Session_End(Object sender, EventArgs e)
    > >
    > > {
    > >
    > > ulong curUsers;
    > >
    > > Application.Lock();
    > >
    > > curUsers = (ulong)Application["curUsers"];
    > >
    > > curUsers--;
    > >
    > > Application["iCurUsers"] = curUsers;
    > >
    > > Application.UnLock();
    > >
    > > }
    > >
    > > Basically, this is supposed to keep track of the number of users that
    are
    > > logged into the system by keeping track of the number of open
    sessions --
    > > except that the Session_End NEVER fires. I've checked my web.config
    file
    > > and it does show the mode as InProc:
    > >
    > > <sessionState
    > >
    > > mode="InProc"
    > >
    > > stateConnectionString="tcpip=127.0.0.1:42424"
    > >
    > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > >
    > > cookieless="false"
    > >
    > > timeout="20"
    > >
    > > />
    > >
    > > Is there something else I missed??
    > >
    > >
    >
    >

    Kevin Spencer Guest

  10. #9

    Default Re: Session_End never fires

    You're right...but my development machine is not going to be where the app
    finally resides and I don't have access to the Event log of that server --
    so I've been trying to make do without using traces...


    "Kevin Spencer" <kevinDIESPAMMERSDIE@takempis.com> wrote in message
    news:eWL#kamRDHA.2144@TK2MSFTNGP11.phx.gbl...
    > BTW, using some try/catch blocks in your code would have helped you debug
    a
    > good bit. For example, you could have the app write an Event Log entry
    with
    > a Stack Trace and the error details when an error occurs. That way you
    would
    > know exactly where any error occurs.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > .Net Developer
    > Microsoft MVP
    > [url]http://www.takempis.com[/url]
    > Big things are made up
    > of lots of little things
    >
    > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > news:Wa0Pa.7212$Vx2.3453809@newssvr28.news.prodigy .com...
    > > Please excuse me for being a freaking newbie. :) I didn't know that
    you
    > > could debug the global.asax.cs file...
    > >
    > > Turns out that the Request object is no longer valid during Session_End
    > (It
    > > says there's an HTML Exception when doing a 'Watch' of the Request
    > object --
    > > but I'm not doing anything weird and I've walked it until the session
    > timed
    > > out -- and the Request object was valid when the page rendered and
    wasn't
    > > when it came back to Session_End...
    > >
    > > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > > news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > > > I've got an ASP.NET page with a counter subtraction routine in the
    > > > Session_End method in the Global.asax.cs:
    > > >
    > > > protected void Session_End(Object sender, EventArgs e)
    > > >
    > > > {
    > > >
    > > > ulong curUsers;
    > > >
    > > > Application.Lock();
    > > >
    > > > curUsers = (ulong)Application["curUsers"];
    > > >
    > > > curUsers--;
    > > >
    > > > Application["iCurUsers"] = curUsers;
    > > >
    > > > Application.UnLock();
    > > >
    > > > }
    > > >
    > > > Basically, this is supposed to keep track of the number of users that
    > are
    > > > logged into the system by keeping track of the number of open
    > sessions --
    > > > except that the Session_End NEVER fires. I've checked my web.config
    > file
    > > > and it does show the mode as InProc:
    > > >
    > > > <sessionState
    > > >
    > > > mode="InProc"
    > > >
    > > > stateConnectionString="tcpip=127.0.0.1:42424"
    > > >
    > > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > > >
    > > > cookieless="false"
    > > >
    > > > timeout="20"
    > > >
    > > > />
    > > >
    > > > Is there something else I missed??
    > > >
    > > >
    > >
    > >
    >
    >

    Kenn Ghannon Guest

  11. #10

    Default Re: Session_End never fires

    Well, what you can do is write a global Error Handler method that all of
    your outermost try/catch blocks use. Then you can change the implementation
    of that Error Handler whenever you feel that it is appropriate for the
    platform you're running the app on. In any case, it's a good idea to have
    some kind of "graceful" error-handling in whatever situation you're in.

    --
    HTH,

    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    [url]http://www.takempis.com[/url]
    Big things are made up
    of lots of little things

    "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    news:an1Pa.7230$Vx2.3463749@newssvr28.news.prodigy .com...
    > You're right...but my development machine is not going to be where the app
    > finally resides and I don't have access to the Event log of that server --
    > so I've been trying to make do without using traces...
    >
    >
    > "Kevin Spencer" <kevinDIESPAMMERSDIE@takempis.com> wrote in message
    > news:eWL#kamRDHA.2144@TK2MSFTNGP11.phx.gbl...
    > > BTW, using some try/catch blocks in your code would have helped you
    debug
    > a
    > > good bit. For example, you could have the app write an Event Log entry
    > with
    > > a Stack Trace and the error details when an error occurs. That way you
    > would
    > > know exactly where any error occurs.
    > >
    > > --
    > > HTH,
    > >
    > > Kevin Spencer
    > > .Net Developer
    > > Microsoft MVP
    > > [url]http://www.takempis.com[/url]
    > > Big things are made up
    > > of lots of little things
    > >
    > > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > > news:Wa0Pa.7212$Vx2.3453809@newssvr28.news.prodigy .com...
    > > > Please excuse me for being a freaking newbie. :) I didn't know that
    > you
    > > > could debug the global.asax.cs file...
    > > >
    > > > Turns out that the Request object is no longer valid during
    Session_End
    > > (It
    > > > says there's an HTML Exception when doing a 'Watch' of the Request
    > > object --
    > > > but I'm not doing anything weird and I've walked it until the session
    > > timed
    > > > out -- and the Request object was valid when the page rendered and
    > wasn't
    > > > when it came back to Session_End...
    > > >
    > > > "Kenn Ghannon" <kennyg@ameritech.net> wrote in message
    > > > news:yLAOa.6922$Vx2.3202899@newssvr28.news.prodigy .com...
    > > > > I've got an ASP.NET page with a counter subtraction routine in the
    > > > > Session_End method in the Global.asax.cs:
    > > > >
    > > > > protected void Session_End(Object sender, EventArgs e)
    > > > >
    > > > > {
    > > > >
    > > > > ulong curUsers;
    > > > >
    > > > > Application.Lock();
    > > > >
    > > > > curUsers = (ulong)Application["curUsers"];
    > > > >
    > > > > curUsers--;
    > > > >
    > > > > Application["iCurUsers"] = curUsers;
    > > > >
    > > > > Application.UnLock();
    > > > >
    > > > > }
    > > > >
    > > > > Basically, this is supposed to keep track of the number of users
    that
    > > are
    > > > > logged into the system by keeping track of the number of open
    > > sessions --
    > > > > except that the Session_End NEVER fires. I've checked my web.config
    > > file
    > > > > and it does show the mode as InProc:
    > > > >
    > > > > <sessionState
    > > > >
    > > > > mode="InProc"
    > > > >
    > > > > stateConnectionString="tcpip=127.0.0.1:42424"
    > > > >
    > > > > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > > > >
    > > > > cookieless="false"
    > > > >
    > > > > timeout="20"
    > > > >
    > > > > />
    > > > >
    > > > > Is there something else I missed??
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Kevin Spencer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139