Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > session_end when triggerd?

Reply
Thread Tools

session_end when triggerd?

 
 
gce
Guest
Posts: n/a
 
      04-05-2005
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


 
Reply With Quote
 
 
 
 
Andy Fish
Guest
Posts: n/a
 
      04-05-2005
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" <(E-Mail Removed)> wrote in message
news:d2uaq3$jo0$(E-Mail Removed)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
>



 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      04-05-2005
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" <(E-Mail Removed)> a écrit dans le message de
news:d2uaq3$jo0$(E-Mail Removed)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
>
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      04-05-2005
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" <(E-Mail Removed)> wrote in message
news:d2uaq3$jo0$(E-Mail Removed)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
>



 
Reply With Quote
 
gce
Guest
Posts: n/a
 
      04-05-2005
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.


 
Reply With Quote
 
Andy Fish
Guest
Posts: n/a
 
      04-06-2005
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" <(E-Mail Removed)> wrote in message
news:d2uf15$n76$(E-Mail Removed)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.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Session_End Kevin Spencer ASP .Net 4 08-15-2003 04:55 PM
Session lasting too long -- Session_End event firing way late !! ?? Steve M ASP .Net 5 07-31-2003 09:44 AM
Session_End never fires Kenn Ghannon ASP .Net 9 07-10-2003 02:49 PM
session_end and re-login Burak Kadirbeyoglu ASP .Net 1 07-10-2003 02:00 PM
Session_End Not Firing Chris Sibel ASP .Net 2 07-02-2003 08:04 PM



Advertisments