Session_End not firing

C

Calvin Willman

ASP.NET 2.0, Visual Web Developer Express

I've written a web app, which creates a Gif to display on the page. I name
it [SessionID].gif, and only want it to last as long as the session, so I've
included

File.Delete([filepath]) in the Session_End event, but this never seems to
run. I've set break points which are never reached...

I've added <sessionState mode="InProc" /> to the web.config file...

what's the problem??

Thanks in advance
 
H

Hans Kesting

ASP.NET 2.0, Visual Web Developer Express
I've written a web app, which creates a Gif to display on the page. I name it
[SessionID].gif, and only want it to last as long as the session, so I've
included

File.Delete([filepath]) in the Session_End event, but this never seems to
run. I've set break points which are never reached...

I've added <sessionState mode="InProc" /> to the web.config file...

what's the problem??

Thanks in advance

When do you expect that Session_End to run?

It will run when the session times out, which is by default 20 minutes
after the last page has been requested.

Hans Kesting
 
C

Calvin Willman

Thanks for your reply Hans,
I'm expecting it to run when the user closes the browser...

It's strange. I think it's working, but it's taking roughly 3 minutes for
the image to actually disappear from the folder. Also, the break point is
never encountered.

I've been testing including the <sessionState> element in the web.config
file in the Windows\Microsoft.Net\Config folder and I think it is that which
is making it work, rather than the application's web.config file. Infact I'm
pretty sure it's only working if I put it in the Windows directory.

It's very annoying, as using Session_End was fine in VS 2003.

Hans Kesting said:
ASP.NET 2.0, Visual Web Developer Express

I've written a web app, which creates a Gif to display on the page. I
name it [SessionID].gif, and only want it to last as long as the session,
so I've included

File.Delete([filepath]) in the Session_End event, but this never seems to
run. I've set break points which are never reached...

I've added <sessionState mode="InProc" /> to the web.config file...

what's the problem??

Thanks in advance

When do you expect that Session_End to run?

It will run when the session times out, which is by default 20 minutes
after the last page has been requested.

Hans Kesting
 
R

Ray Booysen

You'll never get it to fire when the browser closes as IIS cannot know
when this happens. It fires when the session expires or is explicitly
closed.

I don't understand because you are seeing the correct behavior after 3
minutes. Isn't this what you want?

Regards
Ray

Calvin said:
Thanks for your reply Hans,
I'm expecting it to run when the user closes the browser...

It's strange. I think it's working, but it's taking roughly 3 minutes for
the image to actually disappear from the folder. Also, the break point is
never encountered.

I've been testing including the <sessionState> element in the web.config
file in the Windows\Microsoft.Net\Config folder and I think it is that which
is making it work, rather than the application's web.config file. Infact I'm
pretty sure it's only working if I put it in the Windows directory.

It's very annoying, as using Session_End was fine in VS 2003.

Hans Kesting said:
ASP.NET 2.0, Visual Web Developer Express

I've written a web app, which creates a Gif to display on the page. I
name it [SessionID].gif, and only want it to last as long as the session,
so I've included

File.Delete([filepath]) in the Session_End event, but this never seems to
run. I've set break points which are never reached...

I've added <sessionState mode="InProc" /> to the web.config file...

what's the problem??

Thanks in advance
When do you expect that Session_End to run?

It will run when the session times out, which is by default 20 minutes
after the last page has been requested.

Hans Kesting
 
M

Marina Levit [MVP]

In addition to what Ray said, if you search the newsgroups you will find
hundreds of posts identical to yours, and responses to those posts that
explain all the various reasons why this cannot happen.

Calvin Willman said:
Thanks for your reply Hans,
I'm expecting it to run when the user closes the browser...

It's strange. I think it's working, but it's taking roughly 3 minutes for
the image to actually disappear from the folder. Also, the break point is
never encountered.

I've been testing including the <sessionState> element in the web.config
file in the Windows\Microsoft.Net\Config folder and I think it is that
which is making it work, rather than the application's web.config file.
Infact I'm pretty sure it's only working if I put it in the Windows
directory.

It's very annoying, as using Session_End was fine in VS 2003.

Hans Kesting said:
ASP.NET 2.0, Visual Web Developer Express

I've written a web app, which creates a Gif to display on the page. I
name it [SessionID].gif, and only want it to last as long as the
session, so I've included

File.Delete([filepath]) in the Session_End event, but this never seems
to run. I've set break points which are never reached...

I've added <sessionState mode="InProc" /> to the web.config file...

what's the problem??

Thanks in advance

When do you expect that Session_End to run?

It will run when the session times out, which is by default 20 minutes
after the last page has been requested.

Hans Kesting
 
C

Calvin Willman

The correct behavious only occurs if <sessionstate> element is in web.config
in Windows directory.

So... if I publish this to a remote site, I'm wondering if I'm going to have
problems as I won't have access to amend this file to make sure the correct
mode is in place on the webserver.

I'll have to think of something else... maybe sweep the folder to delete
files over a certain date.

The image is a proof of a business card, that a user will order or not... I
suppose I could set it to delete once the order is placed.

Thanks anyway for all your comments.

Ray Booysen said:
You'll never get it to fire when the browser closes as IIS cannot know
when this happens. It fires when the session expires or is explicitly
closed.

I don't understand because you are seeing the correct behavior after 3
minutes. Isn't this what you want?

Regards
Ray

Calvin said:
Thanks for your reply Hans,
I'm expecting it to run when the user closes the browser...

It's strange. I think it's working, but it's taking roughly 3 minutes for
the image to actually disappear from the folder. Also, the break point is
never encountered.

I've been testing including the <sessionState> element in the web.config
file in the Windows\Microsoft.Net\Config folder and I think it is that
which is making it work, rather than the application's web.config file.
Infact I'm pretty sure it's only working if I put it in the Windows
directory.

It's very annoying, as using Session_End was fine in VS 2003.

Hans Kesting said:
ASP.NET 2.0, Visual Web Developer Express

I've written a web app, which creates a Gif to display on the page. I
name it [SessionID].gif, and only want it to last as long as the
session, so I've included

File.Delete([filepath]) in the Session_End event, but this never seems
to run. I've set break points which are never reached...

I've added <sessionState mode="InProc" /> to the web.config file...

what's the problem??

Thanks in advance
When do you expect that Session_End to run?

It will run when the session times out, which is by default 20 minutes
after the last page has been requested.

Hans Kesting
 
C

Calvin Willman

Actually, that's not true... it works with the application web.config as
well, but it's just a little unpredicably..

I'm a little hungover today so that's probably not helping.

Calvin Willman said:
The correct behavious only occurs if <sessionstate> element is in
web.config in Windows directory.

So... if I publish this to a remote site, I'm wondering if I'm going to
have problems as I won't have access to amend this file to make sure the
correct mode is in place on the webserver.

I'll have to think of something else... maybe sweep the folder to delete
files over a certain date.

The image is a proof of a business card, that a user will order or not...
I suppose I could set it to delete once the order is placed.

Thanks anyway for all your comments.

Ray Booysen said:
You'll never get it to fire when the browser closes as IIS cannot know
when this happens. It fires when the session expires or is explicitly
closed.

I don't understand because you are seeing the correct behavior after 3
minutes. Isn't this what you want?

Regards
Ray

Calvin said:
Thanks for your reply Hans,
I'm expecting it to run when the user closes the browser...

It's strange. I think it's working, but it's taking roughly 3 minutes
for the image to actually disappear from the folder. Also, the break
point is never encountered.

I've been testing including the <sessionState> element in the web.config
file in the Windows\Microsoft.Net\Config folder and I think it is that
which is making it work, rather than the application's web.config file.
Infact I'm pretty sure it's only working if I put it in the Windows
directory.

It's very annoying, as using Session_End was fine in VS 2003.

ASP.NET 2.0, Visual Web Developer Express

I've written a web app, which creates a Gif to display on the page. I
name it [SessionID].gif, and only want it to last as long as the
session, so I've included

File.Delete([filepath]) in the Session_End event, but this never seems
to run. I've set break points which are never reached...

I've added <sessionState mode="InProc" /> to the web.config file...

what's the problem??

Thanks in advance
When do you expect that Session_End to run?

It will run when the session times out, which is by default 20 minutes
after the last page has been requested.

Hans Kesting
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top