views:

24

answers:

2

I put break point inside Session_OnEnd in Global.asax, it seems the ASP.NET application never stop when I try to debug, any thing I missed? But I debug Session_OnStart.

+1  A: 

First of all try to add some dummy code in your session_OnEnd.

Set the session timeout in the web.config for example to one minute. This should work.

Edit:

Wait for one minute and the breakpoint will be hit.

pipelinecache
A: 

First of all, the Session_OnEnd event doesn't occur when the application stops, it occurs when a session ends.

A session ends by default 20 minutes after the last page was requested by the user. If you wait that long you might see the break point being hit. (The event is executed in a different environment than a regular page, so I'm not certain that the debugger can ever catch a break point there.)

It's a fairly common misconception that the session ends when the user closes the browser window, but the fact is that the server is not at all aware of the browser window being closed. The server only knows about the pages that are requested, it has no means of knowing whether the page is still displayed in a browser or not.

Guffa
It can be debugged. Meet the requirements like I wrote, and it will be hit.
pipelinecache
btw, forms auth session timeout is 30 by default
abatishchev
@abatishchev: Perhaps, but that is something different.
Guffa
Forms auth timeout expiration will reset `HttpContext.Session`, will it not?
abatishchev
@abatishchev: It might, if you are using forms authentication, but there's nothing in the question that suggests that.
Guffa