473,387 Members | 1,579 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,387 software developers and data experts.

Site Unload?

I want to have an onUnload that runs only when the site is left, not when
the current page is unloaded. Any ideas?

Thanks!

Ross
Jul 23 '05 #1
35 1760
Is there no solution?

"Ross M. Greenberg" <gr******@catskill.net> wrote in message
news:10*************@corp.supernews.com...
I want to have an onUnload that runs only when the site is left, not when
the current page is unloaded. Any ideas?

Thanks!

Ross

Jul 23 '05 #2
You will have to know before the unload where the client is going and
as far as I know there is no built in way of knowing that via the DOM.
The only way I can think of accomplishing this is to set an "isLeaving"
flag on every page of your site and default it to true. Whenever you
navigate to another page in your site you will have to set it to false.
Then in the unload you can check to see the status of the flag.

This method will probably turn into pain in the ass to do on every page
(although you may be able to trap most items with a script to chase
down onSubmit onClick events) but I can't think of a better way.
Anyone else?

Jul 23 '05 #3
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:
I want to have an onUnload that runs only when the site is left, not when
the current page is unloaded. Any ideas?


"site is left" is not defined,
[unless you have a button saying "I solemnly declare to leave the site"]

With serverside ASP scripting you could do something ON THE SERVER when a
session ends. This is not very reliable and has no effect on clientside.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #4
Sigh. There has to be something for this!
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:
I want to have an onUnload that runs only when the site is left, not when the current page is unloaded. Any ideas?


"site is left" is not defined,
[unless you have a button saying "I solemnly declare to leave the site"]

With serverside ASP scripting you could do something ON THE SERVER when a
session ends. This is not very reliable and has no effect on clientside.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 23 '05 #5
On Tue, 14 Dec 2004 14:30:41 -0500, Ross M. Greenberg
<gr******@catskill.net> wrote:
Sigh. There has to be something for this!


Why? There's no guarantee that the browser will actually execute *any*
code when the user chooses to close it.

[snip]

Mike
Please don't top-post.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #6
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:
Sigh. There has to be something for this!


[Please do not topost on usenet]

No, you cannot detect something that is not defined.

"leaving a site" in the logical sense has no meaning to me.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #7
On Tue, 14 Dec 2004 19:33:27 GMT, Michael Winter
<M.******@blueyonder.co.invalid> wrote:
There's no guarantee that the browser will actually execute *any* code
when the user chooses to close it.


....or leave your pages.

What are you trying to achieve, and why?

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #8
For a commercial site, I want to open a survey page when they exit from the
site from any page, but not as they transit along the site's many pages.
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsi0kwiy0x13kvk@atlantis...
On Tue, 14 Dec 2004 19:33:27 GMT, Michael Winter
<M.******@blueyonder.co.invalid> wrote:
There's no guarantee that the browser will actually execute *any* code
when the user chooses to close it.


...or leave your pages.

What are you trying to achieve, and why?

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Jul 23 '05 #9

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:
Sigh. There has to be something for this!


[Please do not topost on usenet]

No, you cannot detect something that is not defined.

"leaving a site" in the logical sense has no meaning to me.


It may not be formally defined, but how about "when the host changes"?

Jul 23 '05 #10
How about defaulting to false, then setting to true with OnLoad, in essense
reversing the sense.

"rubikzube*" <th************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
You will have to know before the unload where the client is going and
as far as I know there is no built in way of knowing that via the DOM.
The only way I can think of accomplishing this is to set an "isLeaving"
flag on every page of your site and default it to true. Whenever you
navigate to another page in your site you will have to set it to false.
Then in the unload you can check to see the status of the flag.

This method will probably turn into pain in the ass to do on every page
(although you may be able to trap most items with a script to chase
down onSubmit onClick events) but I can't think of a better way.
Anyone else?

Jul 23 '05 #11
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:
> Sigh. There has to be something for this!
[Please do not topost on usenet]

No, you cannot detect something that is not defined.

"leaving a site" in the logical sense has no meaning to me.


It may not be formally defined,


It is not about a "formal definition", but what YOU mean by it defined in
a technical complete way.
but how about "when the host changes"?


The host of what?
Of a browser page?

Talking IE, when you pass to another page with shift-clicking a link, you
have two pages. Do you define closing one of the pages as leaving a site?

Even if there is one browser page, pulling the mains plug is not
"detected".

=================

Your misconception IMHO is, that, as long as a page is on a browser, you
are "connected" to the "host". This is not true. "Connected" does not
exist in the HTML world.

If your employer wants this,
it is your task as the specialist to explain his/her folly.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #12

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:

> Sigh. There has to be something for this!

[Please do not topost on usenet]

No, you cannot detect something that is not defined.

"leaving a site" in the logical sense has no meaning to me.
It may not be formally defined,


It is not about a "formal definition", but what YOU mean by it defined in
a technical complete way.
but how about "when the host changes"?


The host of what?
Of a browser page?


if I'm at http://www.foo.bar/whatever.htm, then going to
http://www.yahoo.com


Talking IE, when you pass to another page with shift-clicking a link, you
have two pages. Do you define closing one of the pages as leaving a site?
Nope. Just going to a "new" site.
Even if there is one browser page, pulling the mains plug is not
"detected".


That's why I want to detect the address of the page I'm *about* to open,
check the root-site.host and trigger if there's no match.
Jul 23 '05 #13
On Tue, 14 Dec 2004 15:37:42 -0500, Ross M. Greenberg
<gr******@catskill.net> wrote:

Don't top-post and don't quote signatures!
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsi0kwiy0x13kvk@atlantis...


[snip]
What are you trying to achieve, and why?


For a commercial site, I want to open a survey page when they exit from
the site from any page, but not as they transit along the site's many
pages.


I'm afraid I'll have to be blunt: why on Earth should I, or anyone else,
tell you how to do that?

Provide a link to the survey and ask, discreetly, for visitors to fill it
in. If they're willing to do it, they'll activate the link and take the
survey. If they're not willing, they'll get annoyed, close the window, and
may not come back.

Don't annoy your users. It's the sensible, and ethical, thing to do.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #14

"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsi0o0f06x13kvk@atlantis...
On Tue, 14 Dec 2004 15:37:42 -0500, Ross M. Greenberg
<gr******@catskill.net> wrote:

Don't top-post and don't quote signatures!
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsi0kwiy0x13kvk@atlantis...
[snip]
What are you trying to achieve, and why?


For a commercial site, I want to open a survey page when they exit from
the site from any page, but not as they transit along the site's many
pages.


I'm afraid I'll have to be blunt: why on Earth should I, or anyone else,
tell you how to do that?


Aside from the challenge?

Provide a link to the survey and ask, discreetly, for visitors to fill it
in. If they're willing to do it, they'll activate the link and take the
survey. If they're not willing, they'll get annoyed, close the window, and
may not come back.

Don't annoy your users. It's the sensible, and ethical, thing to do.

The survey in mind seeks to ask them directly what they liked or did not
like about the site. I'm seeing more than a few users leaving the site from
its home page. I need to find out why so I can fix what they don't like.
Jul 23 '05 #15
On Tue, 14 Dec 2004 17:35:33 -0500, Ross M. Greenberg
<gr******@catskill.net> wrote:

[Opening a survey when leaving a site]

Whilst it is technically possible, it won't actually serve much purpose
for the reason I mentioned previously: user's generally don't like having
a questionaire shoved in their face. Moreover, if you use a pop-up to
present this survey, every pop-up blocker in existence will prevent it
from appearing.

[snip]
The survey in mind seeks to ask them directly what they liked or did not
like about the site. I'm seeing more than a few users leaving the site
from its home page. I need to find out why so I can fix what they don't
like.


That might depend on your content. For example, users might be arriving
because your site appeared in a search result whilst they're looking for
some information. When they view your site, they may discover that you
don't provide what they were looking for, so they leave. Alternatively,
they may be unsure of whether your site is appropriate and for some reason
- bad navigation or unappealing appearance, for example - they're not
inclined to investigate further.

The people over at alt.www.webmaster might have a few suggestions.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #16
Ross M. Greenberg wrote:
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsi0o0f06x13kvk@atlantis...
On Tue, 14 Dec 2004 15:37:42 -0500, Ross M. Greenberg
<gr******@catskill.net> wrote:

Don't top-post and don't quote signatures!

"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsi0kwiy0x13kvk@atlantis...
[snip]

What are you trying to achieve, and why?

For a commercial site, I want to open a survey page when they exit from
the site from any page, but not as they transit along the site's many
pages.


I'm afraid I'll have to be blunt: why on Earth should I, or anyone else,
tell you how to do that?

Aside from the challenge?


You can take this "challenge" for as long as you want, and you will
still ultimately fail in the end. The browser has NO way to know where I
am going, unless its from a link within the page.

But tell us this.

Lets say I am on page234.html on your site.
I have page352.html bookmarked.
I click the page352.html bookmark.

Did I leave the site?

The answer is no but your script will fail to know that.
The survey in mind seeks to ask them directly what they liked or did not
like about the site. I'm seeing more than a few users leaving the site from
its home page. I need to find out why so I can fix what they don't like.


Then put the link on the main page. As was pointed out, if the user
wants to fill it out, they will. <sarcasm>If they don't, then popping up
a survey page will surely entice them to.</sarcasm>

Thats assuming that Scripting is enabled and that you can actually open
a survey page.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #17
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:
The host of what?
Of a browser page?


if I'm at http://www.foo.bar/whatever.htm, then going to
http://www.yahoo.com


That is no answer to my question. You are not going from one place to
another but your browser page is. But another pge can stay on the old
host. The host OF WHAT?

Talking IE, when you pass to another page with shift-clicking a link,
you have two pages. Do you define closing one of the pages as leaving
a site?


Nope. Just going to a "new" site.


Strange. Same objection as above. see below.
Even if there is one browser page, pulling the mains plug is not
"detected".


That's why I want to detect the address of the page I'm *about* to
open, check the root-site.host and trigger if there's no match.


Only by comparing domains in the code could this be accomlished.

It would be an infringement of browser security, if the code of your page
would be able to know the domain of the next page if typed in or
favoritized.

No one in his right mind would want that information to be sent back to
the server of the old page, because all privacy would be gone.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #18

"Randy Webb" <Hi************@aol.com> wrote in message
news:lP********************@comcast.com...
You can take this "challenge" for as long as you want, and you will
still ultimately fail in the end. The browser has NO way to know where I
am going, unless its from a link within the page.
I thought an event was triggered when a web page is about to be accessed --
aren't custom 404's generated locally for invalid URLs, for example?
But tell us this.

Lets say I am on page234.html on your site.
I have page352.html bookmarked.
I click the page352.html bookmark.

Did I leave the site?
If the http://<whatever> is the same, no. If different, yes.
The answer is no but your script will fail to know that.
The survey in mind seeks to ask them directly what they liked or did not
like about the site. I'm seeing more than a few users leaving the site from its home page. I need to find out why so I can fix what they don't like.
Then put the link on the main page. As was pointed out, if the user
wants to fill it out, they will. <sarcasm>If they don't, then popping up
a survey page will surely entice them to.</sarcasm>


But this was a means to get them to let me know *as* they leave, not when
they're still at/just arrived at the site.
Thats assuming that Scripting is enabled and that you can actually open
a survey page.


Well, yeah, there's that, too :-)
Jul 23 '05 #19

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn*******************@194.109.133.29...
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:
The host of what?
Of a browser page?
if I'm at http://www.foo.bar/whatever.htm, then going to
http://www.yahoo.com


That is no answer to my question. You are not going from one place to
another but your browser page is. But another pge can stay on the old
host. The host OF WHAT?


The pages stay at the host, obviously. The base of the URL can be considered
the host for these purposes, however.
Only by comparing domains in the code could this be accomlished.

It would be an infringement of browser security, if the code of your page
would be able to know the domain of the next page if typed in or
favoritized.
I had thought the address you were *about* to go to would be available until
the event (onunload) had finished.

No one in his right mind would want that information to be sent back to
the server of the old page, because all privacy would be gone.


Hadn't thought of that....
Jul 23 '05 #20
Ross M. Greenberg wrote:
"Randy Webb" <Hi************@aol.com> wrote in message
news:lP********************@comcast.com...
You can take this "challenge" for as long as you want, and you will
still ultimately fail in the end. The browser has NO way to know where I
am going, unless its from a link within the page.

I thought an event was triggered when a web page is about to be accessed --
aren't custom 404's generated locally for invalid URLs, for example?


That depends on how the server of the invalid URL is setup. But it's
irrelevant.
But tell us this.

Lets say I am on page234.html on your site.
I have page352.html bookmarked.
I click the page352.html bookmark.

Did I leave the site?

If the http://<whatever> is the same, no. If different, yes.


The browser has no way of knowing that. It only knows that you left
*one* page, not how you left, just that the page is unloading. The one
exception would be if you had onclicks in all your links to internal
pages that set a variable, onunload you check that variable. Search the
archives on how its done.

But that still does not cover me leaving one page of your site to
another page of your site via a favorites or by typing in the URL.

The answer is no but your script will fail to know that.

The survey in mind seeks to ask them directly what they liked or did not
like about the site. I'm seeing more than a few users leaving the site
from
its home page. I need to find out why so I can fix what they don't like.


Then put the link on the main page. As was pointed out, if the user
wants to fill it out, they will. <sarcasm>If they don't, then popping up
a survey page will surely entice them to.</sarcasm>

But this was a means to get them to let me know *as* they leave, not when
they're still at/just arrived at the site.


Then put the link on all pages. But if people are going to fill it out,
they will do so. Attempting to popup a survey to ask what you thought of
a site is very anti-user oriented.

But there is no way for you to definitively know where I am going when I
leave one page of your site.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #21
Ross M. Greenberg wrote on 15 dec 2004 in comp.lang.javascript:
I thought an event was triggered when a web page is about to be
accessed -- aren't custom 404's generated locally for invalid URLs,
for example?


No, not if the domain is valid.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #22
I listened to you folks, and stuck the survey via a link.

"Randy Webb" <Hi************@aol.com> wrote in message
news:Se********************@comcast.com...
Ross M. Greenberg wrote:
"Randy Webb" <Hi************@aol.com> wrote in message
news:lP********************@comcast.com...
You can take this "challenge" for as long as you want, and you will
still ultimately fail in the end. The browser has NO way to know where I
am going, unless its from a link within the page.

I thought an event was triggered when a web page is about to be accessed --
aren't custom 404's generated locally for invalid URLs, for example?


That depends on how the server of the invalid URL is setup. But it's
irrelevant.
But tell us this.

Lets say I am on page234.html on your site.
I have page352.html bookmarked.
I click the page352.html bookmark.

Did I leave the site?

If the http://<whatever> is the same, no. If different, yes.


The browser has no way of knowing that. It only knows that you left
*one* page, not how you left, just that the page is unloading. The one
exception would be if you had onclicks in all your links to internal
pages that set a variable, onunload you check that variable. Search the
archives on how its done.

But that still does not cover me leaving one page of your site to
another page of your site via a favorites or by typing in the URL.

The answer is no but your script will fail to know that.
The survey in mind seeks to ask them directly what they liked or did notlike about the site. I'm seeing more than a few users leaving the site


from
its home page. I need to find out why so I can fix what they don't like.
Then put the link on the main page. As was pointed out, if the user
wants to fill it out, they will. <sarcasm>If they don't, then popping up
a survey page will surely entice them to.</sarcasm>

But this was a means to get them to let me know *as* they leave, not when they're still at/just arrived at the site.


Then put the link on all pages. But if people are going to fill it out,
they will do so. Attempting to popup a survey to ask what you thought of
a site is very anti-user oriented.

But there is no way for you to definitively know where I am going when I
leave one page of your site.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #23
Well, I stuck the survey in via a link

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Ross M. Greenberg wrote on 15 dec 2004 in comp.lang.javascript:
I thought an event was triggered when a web page is about to be
accessed -- aren't custom 404's generated locally for invalid URLs,
for example?


No, not if the domain is valid.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 23 '05 #24
Ross M. Greenberg wrote on 15 dec 2004 in comp.lang.javascript:

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Ross M. Greenberg wrote on 15 dec 2004 in comp.lang.javascript:
> I thought an event was triggered when a web page is about to be
> accessed -- aren't custom 404's generated locally for invalid URLs,
> for example?
>


No, not if the domain is valid.


Well, I stuck the survey in via a link


[please do not toppost on usenet]

I don't know what you mean by this.

Is your survey stuck in a link?

;-}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #25
Hi,

Evertjan. wrote:
Ross M. Greenberg wrote on 14 dec 2004 in comp.lang.javascript:

I want to have an onUnload that runs only when the site is left, not when
the current page is unloaded. Any ideas?

"site is left" is not defined,
[unless you have a button saying "I solemnly declare to leave the site"]

With serverside ASP scripting you could do something ON THE SERVER when a
session ends. This is not very reliable and has no effect on clientside.


To be precise, the Session_End event (or similar on other platforms) is
very reliable. It will be called when the Session ends, but the session
often ends on a timeout, typically 20 minutes in ASP.NET, unless the
user is nice enough to press a "Log Off" button (which allows to
terminate the session earlier). The Session_End event *has* to be called
or else the Server process will explode with unroomed resources.

And yes, it has no effect on the client at all.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 23 '05 #26
Laurent Bugnion wrote on 17 dec 2004 in comp.lang.javascript:
With serverside ASP scripting you could do something ON THE SERVER
when a session ends. This is not very reliable and has no effect on
clientside.
To be precise, the Session_End event (or similar on other platforms)
is very reliable. It will be called when the Session ends, but the
session often ends on a timeout, typically 20 minutes in ASP.NET,


I was talking ASP, not ASP.NET
unless the user is nice enough to press a "Log Off" button (which
allows to terminate the session earlier). The Session_End event *has*
to be called or else the Server process will explode with unroomed
resources.
Same, not in ASP classic.
And yes, it has no effect on the client at all.


Paradox: some clients gets mad, because of that lack of effect.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #27
Hi,

Evertjan. wrote:
Laurent Bugnion wrote on 17 dec 2004 in comp.lang.javascript:

With serverside ASP scripting you could do something ON THE SERVER
when a session ends. This is not very reliable and has no effect on
clientside.


To be precise, the Session_End event (or similar on other platforms)
is very reliable. It will be called when the Session ends, but the
session often ends on a timeout, typically 20 minutes in ASP.NET,

I was talking ASP, not ASP.NET

unless the user is nice enough to press a "Log Off" button (which
allows to terminate the session earlier). The Session_End event *has*
to be called or else the Server process will explode with unroomed
resources.

Same, not in ASP classic.


That's surprising. I believe you, of course (I am much better in ASP.NET
than ASP), but I find the apparent lack of reliability of this critical
event a huge problem for ASP servers. How do you handle this?

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 23 '05 #28
Laurent Bugnion wrote on 19 dec 2004 in comp.lang.javascript:
unless the user is nice enough to press a "Log Off" button (which
allows to terminate the session earlier). The Session_End event *has*
to be called or else the Server process will explode with unroomed
resources.

Same, not in ASP classic.


That's surprising. I believe you, of course (I am much better in ASP.NET
than ASP), but I find the apparent lack of reliability of this critical
event a huge problem for ASP servers. How do you handle this?


Under ASP, server process will NOT explode.
[Resources are automaticly ended at the end of each page rendering.]

That should make ASP much more reliable than ASP.NET as you describe.

I suppose [I never even tasted it] the problem lies with ASP.NET.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #29
Hi,

Evertjan. wrote:
Laurent Bugnion wrote on 19 dec 2004 in comp.lang.javascript:

unless the user is nice enough to press a "Log Off" button (which
allows to terminate the session earlier). The Session_End event *has*
to be called or else the Server process will explode with unroomed
resources.
Same, not in ASP classic.


That's surprising. I believe you, of course (I am much better in ASP.NET
than ASP), but I find the apparent lack of reliability of this critical
event a huge problem for ASP servers. How do you handle this?

Under ASP, server process will NOT explode.
[Resources are automaticly ended at the end of each page rendering.]

That should make ASP much more reliable than ASP.NET as you describe.

I suppose [I never even tasted it] the problem lies with ASP.NET.


OK, that's the case in ASP.NET too (each Page object is deleted at the
end of every call, and of course its members too), but you also have
Session objects, for example you will save there DB connections, file
contents, "global" variables, etc... IIRC, ASP also have the Application
and Session objects, doesn't it? So my question was, how do you know
when to room the resources saved in the Session object if you don't know
when the said session has timed out?

Sorry, for the more and more OT post, it just made me curious ;-)

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 23 '05 #30
Laurent Bugnion wrote on 20 dec 2004 in comp.lang.javascript:
OK, that's the case in ASP.NET too (each Page object is deleted at the
end of every call, and of course its members too), but you also have
Session objects, for example you will save there DB connections, file
contents, "global" variables, etc... IIRC, ASP also have the Application
and Session objects, doesn't it? So my question was, how do you know
when to room the resources saved in the Session object if you don't know
when the said session has timed out?


Simple, Laurent, you don't.

Data is needed outside the present session should not be kept in session
memory.

The concept of "having a connection" with the client is a flawed one, as
the connection is not ASP but HTML. [I think hiding this fact of live is my
main objection to asp.net, while sold by MS as a bonus. But let our focus
stay on classic ASP.]

All pertinent data that is not to be lost, should be saved during the asp
execution fase of a single page to a serverside database or other file.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #31
Hi,

Evertjan. wrote:
Laurent Bugnion wrote on 20 dec 2004 in comp.lang.javascript:

OK, that's the case in ASP.NET too (each Page object is deleted at the
end of every call, and of course its members too), but you also have
Session objects, for example you will save there DB connections, file
contents, "global" variables, etc... IIRC, ASP also have the Application
and Session objects, doesn't it? So my question was, how do you know
when to room the resources saved in the Session object if you don't know
when the said session has timed out?

Simple, Laurent, you don't.

Data is needed outside the present session should not be kept in session
memory.

The concept of "having a connection" with the client is a flawed one, as
the connection is not ASP but HTML. [I think hiding this fact of live is my
main objection to asp.net, while sold by MS as a bonus. But let our focus
stay on classic ASP.]


I didn't mean connections between the client and the server (I am aware
that HTTP is stateless), but rather connections to databases, which can
remain open for example as long as a certain page is displayed, to avoid
re-connecting to the DB every time the page is refreshed. THis is only
an example, BTW. I can think of multiple reasons to cache data in the
Session object.

I am not sure I understand your objection to ASP.NET, maybe you mean
that it gives the programmer the impression that there is a connection
between the client and the server, since the events are redirected to
the correct event handlers automatically, thus hiding the fact that
there is a Request object and a whole HTTP GET or POST process behind
all this. If that's what you mean, then I can ensure you that this basic
fact of life is hidden only from very basic programmers who make very
small Web Applications. As soon as your application is a bit bigger, you
need to have a good knowledge of the exact processes between every
request/response, believe me ;-)
All pertinent data that is not to be lost, should be saved during the asp
execution fase of a single page to a serverside database or other file.


That's not very efficient to say the least.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 23 '05 #32
Laurent Bugnion wrote on 20 dec 2004 in comp.lang.javascript:
I didn't mean connections between the client and the server (I am
aware that HTTP is stateless), but rather connections to databases,
which can remain open for example as long as a certain page is
displayed, to avoid re-connecting to the DB every time the page is
refreshed. THis is only an example, BTW. I can think of multiple
reasons to cache data in the Session object.
I don't think you can keep a database connection open between pages even
while refreshing the same page [as stateless HTML does not see the
difference between same and other, as long as the page is refetched from
the server.]
I am not sure I understand your objection to ASP.NET, maybe you mean
that it gives the programmer the impression that there is a connection
between the client and the server,
YES
since the events are redirected to
the correct event handlers automatically, thus hiding the fact that
there is a Request object and a whole HTTP GET or POST process behind
all this. If that's what you mean, then I can ensure you that this
basic fact of life is hidden only from very basic programmers who make
very small Web Applications.
I don't think so. It is the reason for ASP.Net, me thinks.
As soon as your application is a bit
bigger, you need to have a good knowledge of the exact processes
between every request/response, believe me ;-)


That is why ASP is more logical, since it doesn't hide those things from
view.
All pertinent data that is not to be lost, should be saved during the
asp execution fase of a single page to a serverside database or other
file.


That's not very efficient to say the least.


Perhaps, but it is a fact of stateless HTML life.

Save it or sometimes loose it. The data, I mean.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #33

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Laurent Bugnion wrote on 20 dec 2004 in comp.lang.javascript:
I didn't mean connections between the client and the server (I am
aware that HTTP is stateless), but rather connections to databases,
which can remain open for example as long as a certain page is
displayed, to avoid re-connecting to the DB every time the page is
refreshed. THis is only an example, BTW. I can think of multiple
reasons to cache data in the Session object.


I don't think you can keep a database connection open between pages
even
while refreshing the same page [as stateless HTML does not see the
difference between same and other, as long as the page is refetched
from
the server.]


It's a common mistake to cache DB connections in the session object.
By doing this you prevent another user from re-using the connection
and actually end up putting more load on the server and the DB by
having to carry a larger number of connection.

If you let it, Windows will handle your connection pooling for you:
when you close a connection it will keep it open for a short time and
re-use it for the next request instead of creating a whole new one.
Once you put the connection object into the session your pooling is
shot.

Tim.

Jul 23 '05 #34
Tim Williams wrote on 21 dec 2004 in comp.lang.javascript:
Once you put the connection object into the session your pooling is
shot.


Do you mean in a session variable?

Since a session variable is only a string,
how can you put an object in a string?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #35
Hi,

Evertjan. wrote:
Tim Williams wrote on 21 dec 2004 in comp.lang.javascript:

Once you put the connection object into the session your pooling is
shot.

Do you mean in a session variable?

Since a session variable is only a string,
how can you put an object in a string?


No, he means (I think) the Session object. In ASP.NET, each Page is an
object, and has one property named Session (of type HttpSessionState),
and this object is a collection in which you can store pretty much
everything you want, including references to other objects.

To Tim: We were not talking necessarily about storing things in the
Session, but rather on the server generally between requests. Other ways
exist in ASP.NET, for example the Application object, static variables,
etc...

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 23 '05 #36

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

Similar topics

5
by: Harry J. Smith | last post by:
I have written a Visual Basic program that does a long calculation and writes the results to disk as it runs. If I click the Close button the window closes but the program keeps running. How can I...
0
by: razheev | last post by:
Hi, I have a Table which contains 1 million rows. I want to do an unload of the table and do some massaging (tranforming) of data and do a load to a different table where the column attributes are...
2
by: Lauren Hines | last post by:
Hello, I have read numerous post stating that the only way to unload an assembly (DLL in my case) is to create a separate AppDomain, load the assembly, then unload it by calling AppDomain.Unload....
1
by: hal | last post by:
I have an application that includes an activex component that consumes resources that must be released when the a page is unloaded. Toward this end I subscribe to the unload event of the body...
1
by: Hal | last post by:
My most sincere gratitude to anyone who can help me work around this! I have work that needs to be done in javascript on the client whenever a page is unloaded. To this end, I subscribe to...
19
by: Jon Davis | last post by:
I'm reposting this because I really need some advice. I have a web app that makes many queries to the database on every page. In order to save development effort, I've consolidated all database...
3
by: Gauthier Segay | last post by:
Hello, I've an application where all my pages implement a PAGE_CODE string property, this property is stored in HttpContext.Current.Items. In some page, I must persist data in session while...
11
by: Timofmars | last post by:
I'm try to Unload DB2 data from a table into a record sequential file on NT. I can an unload on Mainframe, but it doesn't seem to be an option in NT. In NT, all I can do is export/import. I can...
5
by: =?Utf-8?B?QW5keQ==?= | last post by:
As per the question really. Not trying to stop them leaving, but just detect WHEN they leave the site
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.