session_end when triggerd?

Discussion in 'ASP .Net' started by gce, Apr 5, 2005.

  1. gce

    gce Guest

    Hi,

    Every session I make a temp directory using Session("SessieGuid") =
    System.Guid.NewGuid().ToString
    Whenever the user presses a button to end everything or when the
    session.timeout fires up, I need to remove the directory.

    My question :

    1. What command is needed behind the END-button to close the session
    2. And when will session_end will fire up?

    Best regards,
    gert
    gce, Apr 5, 2005
    #1
    1. Advertising

  2. gce

    Andy Fish Guest

    To end the session, I think the best practice is to call

    Session.Clear();
    Session.Abandon();

    in that order.

    if you do this, the Session_End event will be called immediately (in the
    same thread I think). Otherwise it will be called when the user's session is
    timed out, which depends on the <sessionState timeout="..." > in
    web.config.

    AFAIK, this only works with <sessionState mode="InProc"> which is the
    default.

    Andy


    "gce" <> wrote in message
    news:d2uaq3$jo0$1.ov.home.nl...
    > Hi,
    >
    > Every session I make a temp directory using Session("SessieGuid") =
    > System.Guid.NewGuid().ToString
    > Whenever the user presses a button to end everything or when the
    > session.timeout fires up, I need to remove the directory.
    >
    > My question :
    >
    > 1. What command is needed behind the END-button to close the session
    > 2. And when will session_end will fire up?
    >
    > Best regards,
    > gert
    >
    Andy Fish, Apr 5, 2005
    #2
    1. Advertising

  3. gce

    Patrice Guest

    Session_end occurs twenty minutes (by default) after having no news from the
    user.You can use Session.Abandon to force this.

    Traditionaly this is not considered always reliable (not sure it will fire
    if ASP.NET is recycled) (note also that the SQL Server session provider
    doesn't fire AFAIK this event).

    My personal preference is to have my housekeeping tasks kept independant
    from the application control flow. For example here you could kill those
    dirs one day later or even I would try to see if I really need those
    dirs...(you could name files using those GUIDs, you could make them not
    available on the Internet if this is the case for this scheme etc...)

    Patrice

    --

    "gce" <> a écrit dans le message de
    news:d2uaq3$jo0$1.ov.home.nl...
    > Hi,
    >
    > Every session I make a temp directory using Session("SessieGuid") =
    > System.Guid.NewGuid().ToString
    > Whenever the user presses a button to end everything or when the
    > session.timeout fires up, I need to remove the directory.
    >
    > My question :
    >
    > 1. What command is needed behind the END-button to close the session
    > 2. And when will session_end will fire up?
    >
    > Best regards,
    > gert
    >
    >
    Patrice, Apr 5, 2005
    #3
  4. gce

    Teemu Keiski Guest

    Explicit call to Session.Abandon will end the session and lets End event to
    be raised (which happens when SessionStateModule gets the response for
    postprocessing), but this happens only in InProc session mode.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU

    "gce" <> wrote in message
    news:d2uaq3$jo0$1.ov.home.nl...
    > Hi,
    >
    > Every session I make a temp directory using Session("SessieGuid") =
    > System.Guid.NewGuid().ToString
    > Whenever the user presses a button to end everything or when the
    > session.timeout fires up, I need to remove the directory.
    >
    > My question :
    >
    > 1. What command is needed behind the END-button to close the session
    > 2. And when will session_end will fire up?
    >
    > Best regards,
    > gert
    >
    Teemu Keiski, Apr 5, 2005
    #4
  5. gce

    gce Guest

    I am a relative newbie and an old fashion vb6 programmer so forgive me
    stupid questions.

    I run it on a testserver in vmware locally. In web.config the INPROC is set.
    The session.timer is set to 1 in the session_start part op global.

    I made a button with :

    session.clear
    session.abandon

    but the statements that are in session_end won't fire up.

    Other options are not there for me. The site is hosted externally and I can
    not do scheduled things there i think.
    gce, Apr 5, 2005
    #5
  6. gce

    Andy Fish Guest

    It looks like you're doing the right thing.

    If you're just going straight in and clicking the end button it may be that
    you do not actually have a session. I'm not 100% sure about this but it's
    possible you need to do a round-trip to the browser to properly establish a
    session i.e. make sure you put something in the session when the page is
    originally displayed.

    if it's not that, try waiting until the session is timed out and see if the
    session_end is fired then. This will tell you whether sessions_end is
    working

    as Patrice said, you should not rely 100% on this mechanism anyway. What I
    do in this situation is put some code into application_start to clear down
    all the directories for all users. Use this in conjunction with the
    session_end.

    Andy



    "gce" <> wrote in message
    news:d2uf15$n76$1.ov.home.nl...
    >I am a relative newbie and an old fashion vb6 programmer so forgive me
    >stupid questions.
    >
    > I run it on a testserver in vmware locally. In web.config the INPROC is
    > set. The session.timer is set to 1 in the session_start part op global.
    >
    > I made a button with :
    >
    > session.clear
    > session.abandon
    >
    > but the statements that are in session_end won't fire up.
    >
    > Other options are not there for me. The site is hosted externally and I
    > can not do scheduled things there i think.
    >
    Andy Fish, Apr 6, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Sibel

    Session_End Not Firing

    Chris Sibel, Jul 2, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,972
    Naveen K Kohli
    Jul 2, 2003
  2. Kenn Ghannon

    Session_End never fires

    Kenn Ghannon, Jul 8, 2003, in forum: ASP .Net
    Replies:
    9
    Views:
    492
    Kevin Spencer
    Jul 10, 2003
  3. Burak Kadirbeyoglu

    session_end and re-login

    Burak Kadirbeyoglu, Jul 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    551
    Tu-Thach
    Jul 10, 2003
  4. Steve M
    Replies:
    5
    Views:
    545
    Yan-Hong Huang[MSFT]
    Jul 31, 2003
  5. Kevin Spencer

    Re: Session_End

    Kevin Spencer, Aug 15, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    461
    Kevin Spencer
    Aug 15, 2003
Loading...

Share This Page