I concur with Juan and Mark. Due to the stateless nature of the web,
session timeout is the most reliable way to determine somebody has left your
site.

Signature
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
>I need to ensure that session variables are removed whenever someone leaves
> my web site. My understanding is that this should be happening
[quoted text clipped - 10 lines]
>
> Ross
> So when does the page.dispose event take place? I'd like to call the
> session.abandon, but I don't know when. I can't call it in the page.unload
> since that defeats the purpose of having it in the first place. If I
> understand you correctly, you're saying that the only way to clear the
> session variables under the conditions I've describe is with the session
> timeout, correct?
Disposed is the last event on the page occured when a it is released
from memory.
If you call Session.Abandon within the page then the session will be
closed even user doesn't leave your site. So, it doesn't help you.
> I need to ensure that session variables are removed whenever someone leaves
> my web site.
Why do you need to remove it like that?
Just make a timeout as it is already suggested, and expired session
will be removed automatically.
Ross Culver - 14 Jun 2007 22:43 GMT
The only reason this is an issue is because I have a gridview that populates
as a result of a user search. The testing team has commented that if they
perform a search, then navigate to some other site and then type the search
page url back into the address line, the result set previously presented
comes up instead of the default view (I have the gridview on a multiview
component). They want the default page to be presented instead of the
gridview. Before you ask, there's a reason why the page is coded to
recreate the grid results upon returning to the page due to the fact that a
user can make a selection from the grid, be directed to a new page and then
return back to the same grid result to continue their search.
Any way, while this is less than perfect, it's certainly not a deal breaker.
Thanks to all for you comments and info.
Ross
>> So when does the page.dispose event take place? I'd like to call the
>> session.abandon, but I don't know when. I can't call it in the
[quoted text clipped - 18 lines]
> Just make a timeout as it is already suggested, and expired session
> will be removed automatically.
Alexey Smirnov - 15 Jun 2007 08:24 GMT
> The only reason this is an issue is because I have a gridview that populates
> as a result of a user search. The testing team has commented that if they
[quoted text clipped - 6 lines]
> user can make a selection from the grid, be directed to a new page and then
> return back to the same grid result to continue their search.
What I can suggest here is to use a postback to navigate users between
the pages
if (Page.IsPostBack) {
recreate_grid_results();
}
// else do nothing (default view)
It would help to avoid this:
> perform a search, then navigate to some other site and then type the search
> page url back into the address line, the result set previously presented
> comes up instead of the default view
So, instead of simple hyperlinks use the LinkButton Control