473,419 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

What Event Occurs When Someone Leaves Your Web Site?

I need to ensure that session variables are removed whenever someone leaves
my web site. My understanding is that this should be happening
automatically with the session mode set to InProc. But it's not. Every
machine I'm testing this on does the same thing, but then again, everyone is
using Internet Explorer 7.0 with multiple tabs active.

Also, this problem just popped up, probably due to a change I've made, but I
don't have a clue what that might have been.

Thanks.

Ross

Jun 14 '07 #1
7 3110
Thanks, Juan.

So Mark is correct, that under these conditions, the only way to clear the
session variables is with the session timeout?

Ross
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eZ**************@TK2MSFTNGP04.phx.gbl...
re:
!What Event Occurs When Someone Leaves Your Web Site?

None.

You can detect when someone closed a page ( body onunload="javascrip..." )
or ( window.onunload )
...but you can't detect when someone leaves your website.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Ross Culver" <rc*****@warrenalloy.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>I need to ensure that session variables are removed whenever someone
leaves
my web site. My understanding is that this should be happening
automatically with the session mode set to InProc. But it's not. Every
machine I'm testing this on does the same thing, but then again, everyone
is
using Internet Explorer 7.0 with multiple tabs active.

Also, this problem just popped up, probably due to a change I've made,
but I
don't have a clue what that might have been.

Thanks.

Ross


Jun 14 '07 #2
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.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Ross Culver" <rc*****@warrenalloy.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I need to ensure that session variables are removed whenever someone leaves
my web site. My understanding is that this should be happening
automatically with the session mode set to InProc. But it's not. Every
machine I'm testing this on does the same thing, but then again, everyone
is
using Internet Explorer 7.0 with multiple tabs active.

Also, this problem just popped up, probably due to a change I've made, but
I
don't have a clue what that might have been.

Thanks.

Ross
Jun 14 '07 #3
"Ross Culver" <rc*****@warrenalloy.comwrote in message
news:OB**************@TK2MSFTNGP04.phx.gbl...
So Mark is correct, that under these conditions, the only way to clear the
session variables is with the session timeout?
Yes he is.

ASP.NET apps (like all HTTP websites) work on the HttpRequest / HttpResponse
architecture.

The client browser sends a request to the server, the server process the
request, the server sends back a response.

The server knows ABSOLUTELY NOTHING WHATSOEVER about what happens on the
client machine after that until / unless the client sends another request.

If the client machine doesn't send another request to the server because
maybe the user navigated to another website or just closed the browser, the
server has no way of knowing...

If you have on-line banking, your bank will almost certainly have advised
you to click on the "Log Out" button (or whatever) as soon as you've
finished checking your account - behind the "Log Out" button will be the
code which calls Session.Abandon() etc...

But if you don't click on the "Log Out" button, that's just too bad - your
session will eventually timeout...

This really is just the way it is...
--
http://www.markrae.net

Jun 14 '07 #4
On Jun 14, 10:27 pm, "Ross Culver" <rcul...@warrenalloy.comwrote:
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.

Jun 14 '07 #5
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
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...
On Jun 14, 10:27 pm, "Ross Culver" <rcul...@warrenalloy.comwrote:
>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.

Jun 14 '07 #6
On Jun 14, 11:43 pm, "Ross Culver" <rcul...@warrenalloy.comwrote:
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.
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

Jun 15 '07 #7
Hi,

Juan T. Llibre wrote:
re:
!What Event Occurs When Someone Leaves Your Web Site?

None.

You can detect when someone closed a page ( body onunload="javascrip..." ) or ( window.onunload )
Even that is unreliable. If JavaScript is deactivated, no such event.
Also, in some browsers, these onunload events have low priority and may
very well never be thrown.
...but you can't detect when someone leaves your website.
Actually, the onunload event is also raised when the user leaves the
website. It is raised everytime that the current page is unloaded, which
means also when it is refreshed. This is why it's very difficult (and
useless, see above) to use these events to notify the server about the
state of the web client.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Jun 15 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Navin | last post by:
which event is fired when a browser is closed. i want to call asp page which deleet some files on the server. i tired using onunload event but it aslo get fired when a page is refreshed. the thing...
86
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that:...
2
by: Ron | last post by:
Hi all Just wondered if there's a list somewhere that explains when the events on forms, reports, etc fire. I'm looking for the order of things. Like, the first event to fire when a new form...
2
by: Shreyash Patel | last post by:
Hi I have a label on my WebPage. When Event A occurs on the Server I want to update the information in the label. So the Event A is not a client event but an event that occurs on the Server. So I...
1
by: Zyrthofar | last post by:
Hi I have three textboxes indicating the individual RGB values of a color. When the user leaves a textbox (Leave event), I check the validity of that number and saves the three values to a set of...
1
by: kmercer46 | last post by:
i want to use a form's OnError event to close the form if an error occurs, but the event is not working. it just brings up the error window with the End and Debug buttons. i remember seeing an...
3
by: Tony | last post by:
I have a WebApp with 3 text boxes and 1 button, as described below. Can someone please explain why the bad scenarios are occurring and better still if they can be prevented or worked-around?...
4
by: Kürþat | last post by:
Hi all, I do some drawing in a form's paint event handler and I have a button on that form. Whenever the mouse enters or leaves the button Form's paint event occurs. Isn't that a strange...
16
by: AdamOnAccess | last post by:
I'm trying to trigger some code to fire right after a user enters their first character into any field in the record. I can't seem to identify the proper event. I'm having a little difficulty...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.