Page_Unload event fires to early

H

Heidi Hundåla

Hi !

I have a Wep App in C#.
Page_Unload fires after Page_Load, and
it seems totally unreasonable when you want to use this event when you
_leave_ the page.

In my project we wanted to use the Page_Unload - event to clean up the
Session variables, but
when it turns out that it fires before the end, it screws up the code, and
we get NullPointerExceptions.

Anyone ?

Regards,
Heidi

(e-mail address removed)
 
H

Heidi Hundåla

But I wonder what is the best way to clean up Session when going to one page
from another ?

Session is only taken care of by the garbage collector when the Session
itself is dead, hence
the session can carry a lot of unecesarry stuff for a long time, and this is
causing the web app to be reset
when the whole application is using to much memory.

-H
 
H

Heidi Hundåla

If you read what I wrote, I don't need any clean up at Session End, but
at "Page End" within the same session, long before Session End.

In other words, there should've been a Page_Leave-event. In lack of this,
what is the
best way to handle clean up in Session when going from one page to another
in a
Web App, whithin a Session ?

-H
 
R

Rajesh.V

Ya me too, being new wanted to do a lot of cleanup, but found that sometimes
the garbage collector had paid a visit before unload fires.
 
J

Jeffrey Tan[MSFT]

Hi Heidi,

Thanks for posting in this group.
The page's unload event is fired immediatly after the load event, this is
determined by the server-client mechanism.
After all the client's requests have been processed by the server, the
server will send all the html code to client, and the objects of the client
is no need for server, so the page will fire it unload event.
For your problem, I think you should handle in the client script's unload
event, and submit a request to the server side. Then in the page's load
event(server side), you can judge the IsPostBack property and handle this
certain request, remove the unnessary session variables.

Hope this helps, if you still have anything unclear, please feel free to
tell me.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Heidi Hundåla" <[email protected]>
| References: <#[email protected]>
<#[email protected]>
<#[email protected]>
<[email protected]>
| Subject: Re: Page_Unload event fires to early
| Date: Wed, 22 Oct 2003 15:21:13 +0200
| Lines: 71
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 160.67.143.13
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:185762
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| If you read what I wrote, I don't need any clean up at Session End, but
| at "Page End" within the same session, long before Session End.
|
| In other words, there should've been a Page_Leave-event. In lack of this,
| what is the
| best way to handle clean up in Session when going from one page to another
| in a
| Web App, whithin a Session ?
|
| -H
|
| | > How about session end event in the global.asax....
| >
| > | > > But I wonder what is the best way to clean up Session when going to
one
| > page
| > > from another ?
| > >
| > > Session is only taken care of by the garbage collector when the
Session
| > > itself is dead, hence
| > > the session can carry a lot of unecesarry stuff for a long time, and
| this
| > is
| > > causing the web app to be reset
| > > when the whole application is using to much memory.
| > >
| > > -H
| > >
| > > | > > > Ya me too, being new wanted to do a lot of cleanup, but found that
| > > sometimes
| > > > the garbage collector had paid a visit before unload fires.
| > > >
| > > > | > > > > Hi !
| > > > >
| > > > > I have a Wep App in C#.
| > > > > Page_Unload fires after Page_Load, and
| > > > > it seems totally unreasonable when you want to use this event when
| you
| > > > > _leave_ the page.
| > > > >
| > > > > In my project we wanted to use the Page_Unload - event to clean up
| the
| > > > > Session variables, but
| > > > > when it turns out that it fires before the end, it screws up the
| code,
| > > and
| > > > > we get NullPointerExceptions.
| > > > >
| > > > > Anyone ?
| > > > >
| > > > > Regards,
| > > > > Heidi
| > > > >
| > > > > (e-mail address removed)
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|
 
J

Jeffrey Tan[MSFT]

Hi Heidi,

Does my suggestion resolve your problem?
If you still have anything unclear, please feel free to let me known.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Heidi Hundåla" <[email protected]>
| References: <#[email protected]>
<#[email protected]>
<#[email protected]>
<[email protected]>
| Subject: Re: Page_Unload event fires to early
| Date: Wed, 22 Oct 2003 15:21:13 +0200
| Lines: 71
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 160.67.143.13
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:185762
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| If you read what I wrote, I don't need any clean up at Session End, but
| at "Page End" within the same session, long before Session End.
|
| In other words, there should've been a Page_Leave-event. In lack of this,
| what is the
| best way to handle clean up in Session when going from one page to another
| in a
| Web App, whithin a Session ?
|
| -H
|
| | > How about session end event in the global.asax....
| >
| > | > > But I wonder what is the best way to clean up Session when going to
one
| > page
| > > from another ?
| > >
| > > Session is only taken care of by the garbage collector when the
Session
| > > itself is dead, hence
| > > the session can carry a lot of unecesarry stuff for a long time, and
| this
| > is
| > > causing the web app to be reset
| > > when the whole application is using to much memory.
| > >
| > > -H
| > >
| > > | > > > Ya me too, being new wanted to do a lot of cleanup, but found that
| > > sometimes
| > > > the garbage collector had paid a visit before unload fires.
| > > >
| > > > | > > > > Hi !
| > > > >
| > > > > I have a Wep App in C#.
| > > > > Page_Unload fires after Page_Load, and
| > > > > it seems totally unreasonable when you want to use this event when
| you
| > > > > _leave_ the page.
| > > > >
| > > > > In my project we wanted to use the Page_Unload - event to clean up
| the
| > > > > Session variables, but
| > > > > when it turns out that it fires before the end, it screws up the
| code,
| > > and
| > > > > we get NullPointerExceptions.
| > > > >
| > > > > Anyone ?
| > > > >
| > > > > Regards,
| > > > > Heidi
| > > > >
| > > > > (e-mail address removed)
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|
 
?

=?iso-8859-1?Q?Heidi_Hund=E5la?=

Hi !

I haven't had time to try it out, but I am also not sure
how to do it.
Do you have an example on how to do this, how to
submit a request to the server side from javascript
using the unload-event ?


Regards,
Heidi
 
?

=?iso-8859-1?Q?Heidi_Hund=E5la?=

No, it is not that simple after all.

When you want to change page in the Web App, you use a
menu to go to a new url, but when the unload-event
submits to the server, the processing stops with this.
The client change of page is not valid anymore.

.....

Any good advice ?

-Heidi
-----Original Message-----

I figured it out, so now I have a method:

I have a hidden value in the form:
<input type="hidden" name="action" value="" />

On body onunload, I submit,
Form1.action.value = 'TidySession';
Form1.submit();

In Page_Load, I check the value:
if( Request.Form["action"] == "TidySession" ){

//Tidy Session

I guess this will work whenever leaving a page.

-H


-----Original Message-----
Hi !

I haven't had time to try it out, but I am also not sure
how to do it.
Do you have an example on how to do this, how to
submit a request to the server side from javascript
using the unload-event ?


Regards,
Heidi
at
Session End, but from
one page to another for
a long time, and to
use this event when Page_Unload -
event to clean up end,
it screws up the
.
.
 
J

Jeffrey Tan[MSFT]

Hi ,

Thanks for your feedback.
I do not quite understand what your "when the unload-event submits to the
server, the processing stops with this.The client change of page is not
valid anymore." means.
In my logic, I think you should handle in the client unload event,(Just as
you original find out), then submit to a delsesssion.aspx page. In the
delsesssion.aspx page's load event(server side), you can do your customized
session variables deletion. Finaly, delsesssion.aspx should use
RegisterClientScriptBlock method to generate a client script to client side
to close this page.
That is delsession.aspx's only purpose is delete the unwanted session
variables and close itself at once.

If you still have anything unclear, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| References: <#[email protected]>
<#[email protected]>
<#[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Page_Unload event fires to early
| Date: Thu, 30 Oct 2003 07:18:23 -0800
| Lines: 191
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: quoted-printable
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOe+Q92PAYlcl7KQwyi0C245QElHg==
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:187546
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| No, it is not that simple after all.
| When you want to change page in the Web App, you use a
| menu to go to a new url, but when the unload-event
| submits to the server, the processing stops with this.
| The client change of page is not valid anymore.
| ....
| Any good advice ?
| -Heidi
| >-----Original Message-----
| >
| >I figured it out, so now I have a method:
| >
| >I have a hidden value in the form:
| ><input type="hidden" name="action" value="" />
| >
| >On body onunload, I submit,
| >Form1.action.value = 'TidySession';
| >Form1.submit();
| >
| >In Page_Load, I check the value:
| >if( Request.Form["action"] == "TidySession" ){
| >
| > //Tidy Session
| >
| >I guess this will work whenever leaving a page.
| >
| >-H
| >
| >
| >
| >>-----Original Message-----
| >>Hi !
| >>
| >>I haven't had time to try it out, but I am also not sure
| >>how to do it.
| >>Do you have an example on how to do this, how to
| >>submit a request to the server side from javascript
| >>using the unload-event ?
| >>
| >>
| >>Regards,
| >>Heidi
| >>
| >>>-----Original Message-----
| >>>
| >>>Hi Heidi,
| >>>
| >>>Does my suggestion resolve your problem?
| >>>If you still have anything unclear, please feel free to
| >>let me known.
| >>>
| >>>Best regards,
| >>>Jeffrey Tan
| >>>Microsoft Online Partner Support
| >>>Get Secure! - www.microsoft.com/security
| >>>This posting is provided "as is" with no warranties and
| >>confers no rights.
| >>>
| >>>--------------------
| >>>| From: "Heidi Hundåla" <[email protected]>
| >>>| References: <#[email protected]>
| >>><#[email protected]>
| >>><#[email protected]>
| >>><[email protected]>
| >>>| Subject: Re: Page_Unload event fires to early
| >>>| Date: Wed, 22 Oct 2003 15:21:13 +0200
| >>>| Lines: 71
| >>>| X-Priority: 3
| >>>| X-MSMail-Priority: Normal
| >>>| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| >>>| X-MimeOLE: Produced By Microsoft MimeOLE
| >V6.00.2800.1165
| >>>| Message-ID: <#[email protected]>
| >>>| Newsgroups: microsoft.public.dotnet.framework.aspnet
| >>>| NNTP-Posting-Host: 160.67.143.13
| >>>| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!
| >>TK2MSFTNGP10.phx.gbl
| >>>| Xref: cpmsftngxa06.phx.gbl
| >>microsoft.public.dotnet.framework.aspnet:185762
| >>>| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| >>>|
| >>>| If you read what I wrote, I don't need any clean up
| at
| >>Session End, but
| >>>| at "Page End" within the same session, long before
| >>Session End.
| >>>|
| >>>| In other words, there should've been a Page_Leave-
| >>event. In lack of this,
| >>>| what is the
| >>>| best way to handle clean up in Session when going
| from
| >>one page to another
| >>>| in a
| >>>| Web App, whithin a Session ?
| >>>|
| >>>| -H
| >>>|
| message
| >>>| | >>>| > How about session end event in the global.asax....
| >>>| >
| >>message
| >>>| > | >>>| > > But I wonder what is the best way to clean up
| >>Session when going to
| >>>one
| >>>| > page
| >>>| > > from another ?
| >>>| > >
| >>>| > > Session is only taken care of by the garbage
| >>collector when the
| >>>Session
| >>>| > > itself is dead, hence
| >>>| > > the session can carry a lot of unecesarry stuff
| >for
| >>a long time, and
| >>>| this
| >>>| > is
| >>>| > > causing the web app to be reset
| >>>| > > when the whole application is using to much
| memory.
| >>>| > >
| >>>| > > -H
| >>>| > >
| >>message
| >>>| > > | >>>| > > > Ya me too, being new wanted to do a lot of
| >>cleanup, but found that
| >>>| > > sometimes
| >>>| > > > the garbage collector had paid a visit before
| >>unload fires.
| >>>| > > >
| >>message
| >>>| > > > | >>>| > > > > Hi !
| >>>| > > > >
| >>>| > > > > I have a Wep App in C#.
| >>>| > > > > Page_Unload fires after Page_Load, and
| >>>| > > > > it seems totally unreasonable when you want
| to
| >>use this event when
| >>>| you
| >>>| > > > > _leave_ the page.
| >>>| > > > >
| >>>| > > > > In my project we wanted to use the
| >Page_Unload -
| >> event to clean up
| >>>| the
| >>>| > > > > Session variables, but
| >>>| > > > > when it turns out that it fires before the
| >end,
| >>it screws up the
| >>>| code,
| >>>| > > and
| >>>| > > > > we get NullPointerExceptions.
| >>>| > > > >
| >>>| > > > > Anyone ?
| >>>| > > > >
| >>>| > > > > Regards,
| >>>| > > > > Heidi
| >>>| > > > >
| >>>| > > > > (e-mail address removed)
| >>>| > > > >
| >>>| > > > >
| >>>| > > >
| >>>| > > >
| >>>| > >
| >>>| > >
| >>>| >
| >>>| >
| >>>|
| >>>|
| >>>|
| >>>
| >>>.
| >>>
| >>.
| >>
| >.
| >
|
 
?

=?iso-8859-1?Q?Heidi_Hund=E5la?=

I'll try to explain more accurately. The Wep App has a
menu which is written in a div-tag, like
<div>
<a href="http://myurl/newPage.aspx">New Page</a>
</div>

When you use this menu in order to go from the current
page to New Page, the unload event is fired. The unload
event posts to the server, hence the menu-choice isn't
happening. Current page stays, no New Page.

See ?

There are different Session variables to clean up
depending on each page, hence the clean is not easily
generalized, and posting to a delsesssion.aspx between
each page change seems to be too much just for a
few "nulls".

I just want a solution where the session cleanup is on the
server side (aspx.cs) of each aspx-page with the
possibility to navigate using the div-menu.

Regards,
Heidi

-----Original Message-----

Hi ,

Thanks for your feedback.
I do not quite understand what your "when the unload- event submits to the
server, the processing stops with this.The client change of page is not
valid anymore." means.
In my logic, I think you should handle in the client unload event,(Just as
you original find out), then submit to a delsesssion.aspx page. In the
delsesssion.aspx page's load event(server side), you can do your customized
session variables deletion. Finaly, delsesssion.aspx should use
RegisterClientScriptBlock method to generate a client script to client side
to close this page.
That is delsession.aspx's only purpose is delete the unwanted session
variables and close itself at once.

If you still have anything unclear, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| References: <#[email protected]>
<#[email protected]>
<#[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Page_Unload event fires to early
| Date: Thu, 30 Oct 2003 07:18:23 -0800
| Lines: 191
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: quoted-printable
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOe+Q92PAYlcl7KQwyi0C245QElHg==
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:187546
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| No, it is not that simple after all.
| When you want to change page in the Web App, you use a
| menu to go to a new url, but when the unload-event
| submits to the server, the processing stops with this.
| The client change of page is not valid anymore.
| ....
| Any good advice ?
| -Heidi
| >-----Original Message-----
| >
| >I figured it out, so now I have a method:
| >
| >I have a hidden value in the form:
| ><input type="hidden" name="action" value="" />
| >
| >On body onunload, I submit,
| >Form1.action.value = 'TidySession';
| >Form1.submit();
| >
| >In Page_Load, I check the value:
| >if( Request.Form["action"] == "TidySession" ){
| >
| > //Tidy Session
| >
| >I guess this will work whenever leaving a page.
| >
| >-H
| >
| >
| >
| >>-----Original Message-----
| >>Hi !
| >>
| >>I haven't had time to try it out, but I am also not sure
| >>how to do it.
| >>Do you have an example on how to do this, how to
| >>submit a request to the server side from javascript
| >>using the unload-event ?
| >>
| >>
| >>Regards,
| >>Heidi
| >>
| >>>-----Original Message-----
| >>>
| >>>Hi Heidi,
| >>>
| >>>Does my suggestion resolve your problem?
| >>>If you still have anything unclear, please feel free to
| >>let me known.
| >>>
| >>>Best regards,
| >>>Jeffrey Tan
| >>>Microsoft Online Partner Support
| >>>Get Secure! - www.microsoft.com/security
| >>>This posting is provided "as is" with no warranties and
| >>confers no rights.
| >>>
| >>>--------------------
| >>>| From: "Heidi Hundåla" <[email protected]>
| >>>| References:
 
J

Jeffrey Tan[MSFT]

Hi ,

I have done some research for you. I find that there is some problem before
your issue.
I find that the onunload client script event can not submit form to a page.
I think when the client onunload event fires, the form has been destroyed,
so the form can not be submited. Code like this:
<script language="javascript">
function notifythepage()
{
alert("method called!");
document.Form1.submit();
}
<body onunload="notifythepage()">
</script>
<form name="Form1" method="post" action="delsession.aspx">
</form>
</body>

When you close the page, the alert("method called!"); will be called which
means the method is called while the onunload event.
But the delsession.aspx did not get called. which means the Form1 did not
submit to the delsession.aspx.

So I am thinking of another way of workaround.
1. If you close the IE page, open another IE page and visit the server.
Then you can check the cookie's session id(it will differ). So you can
remove some session variables.
2. If you use link navigate to another page, you can use server side link
button, and it will notify the server, then you can get the notify and
remove some session variables.

If you have anything unclear, please feel free to let me know.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| References: <#[email protected]>
<#[email protected]>
<#[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Page_Unload event fires to early
| Date: Fri, 31 Oct 2003 01:56:51 -0800
| Lines: 298
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: quoted-printable
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOflU5lVhkMS6U7QaaVl6R6SJIhOQ==
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:187752
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I'll try to explain more accurately. The Wep App has a
| menu which is written in a div-tag, like
| <div>
| <a href="http://myurl/newPage.aspx">New Page</a>
| </div>
| When you use this menu in order to go from the current
| page to New Page, the unload event is fired. The unload
| event posts to the server, hence the menu-choice isn't
| happening. Current page stays, no New Page.
| See ?
| There are different Session variables to clean up
| depending on each page, hence the clean is not easily
| generalized, and posting to a delsesssion.aspx between
| each page change seems to be too much just for a
| few "nulls".
| I just want a solution where the session cleanup is on the
| server side (aspx.cs) of each aspx-page with the
| possibility to navigate using the div-menu.
| Regards,
| Heidi
| >-----Original Message-----
| >
| >Hi ,
| >
| >Thanks for your feedback.
| >I do not quite understand what your "when the unload-
| event submits to the
| >server, the processing stops with this.The client change
| of page is not
| >valid anymore." means.
| >In my logic, I think you should handle in the client
| unload event,(Just as
| >you original find out), then submit to a delsesssion.aspx
| page. In the
| >delsesssion.aspx page's load event(server side), you can
| do your customized
| >session variables deletion. Finaly, delsesssion.aspx
| should use
| >RegisterClientScriptBlock method to generate a client
| script to client side
| >to close this page.
| >That is delsession.aspx's only purpose is delete the
| unwanted session
| >variables and close itself at once.
| >
| >If you still have anything unclear, please feel free to
| tell me.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><[email protected]>
| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><[email protected]>
| >| References: <#[email protected]>
| ><#[email protected]>
| ><#[email protected]>
| ><[email protected]>
| ><#[email protected]>
| ><[email protected]>
| ><[email protected]>
| ><[email protected]>
| >| Subject: Re: Page_Unload event fires to early
| >| Date: Thu, 30 Oct 2003 07:18:23 -0800
| >| Lines: 191
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: quoted-printable
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcOe+Q92PAYlcl7KQwyi0C245QElHg==
| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet:187546
| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| >|
| >| No, it is not that simple after all.
| >| When you want to change page in the Web App, you use a
| >| menu to go to a new url, but when the unload-event
| >| submits to the server, the processing stops with this.
| >| The client change of page is not valid anymore.
| >| ....
| >| Any good advice ?
| >| -Heidi
| >| >-----Original Message-----
| >| >
| >| >I figured it out, so now I have a method:
| >| >
| >| >I have a hidden value in the form:
| >| ><input type="hidden" name="action" value="" />
| >| >
| >| >On body onunload, I submit,
| >| >Form1.action.value = 'TidySession';
| >| >Form1.submit();
| >| >
| >| >In Page_Load, I check the value:
| >| >if( Request.Form["action"] == "TidySession" ){
| >| >
| >| > //Tidy Session
| >| >
| >| >I guess this will work whenever leaving a page.
| >| >
| >| >-H
| >| >
| >| >
| >| >
| >| >>-----Original Message-----
| >| >>Hi !
| >| >>
| >| >>I haven't had time to try it out, but I am also not
| sure
| >| >>how to do it.
| >| >>Do you have an example on how to do this, how to
| >| >>submit a request to the server side from javascript
| >| >>using the unload-event ?
| >| >>
| >| >>
| >| >>Regards,
| >| >>Heidi
| >| >>
| >| >>>-----Original Message-----
| >| >>>
| >| >>>Hi Heidi,
| >| >>>
| >| >>>Does my suggestion resolve your problem?
| >| >>>If you still have anything unclear, please feel free
| to
| >| >>let me known.
| >| >>>
| >| >>>Best regards,
| >| >>>Jeffrey Tan
| >| >>>Microsoft Online Partner Support
| >| >>>Get Secure! - www.microsoft.com/security
| >| >>>This posting is provided "as is" with no warranties
| and
| >| >>confers no rights.
| >| >>>
| >| >>>--------------------
| >| >>>| From: "Heidi Hundåla" <[email protected]>
| >| >>>| References:
| <#[email protected]>
| >| >>><#[email protected]>
| >| >>><#[email protected]>
| >| >>><[email protected]>
| >| >>>| Subject: Re: Page_Unload event fires to early
| >| >>>| Date: Wed, 22 Oct 2003 15:21:13 +0200
| >| >>>| Lines: 71
| >| >>>| X-Priority: 3
| >| >>>| X-MSMail-Priority: Normal
| >| >>>| X-Newsreader: Microsoft Outlook Express
| 6.00.2800.1158
| >| >>>| X-MimeOLE: Produced By Microsoft MimeOLE
| >| >V6.00.2800.1165
| >| >>>| Message-ID: <#[email protected]>
| >| >>>| Newsgroups:
| microsoft.public.dotnet.framework.aspnet
| >| >>>| NNTP-Posting-Host: 160.67.143.13
| >| >>>| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!
| >| >>TK2MSFTNGP10.phx.gbl
| >| >>>| Xref: cpmsftngxa06.phx.gbl
| >| >>microsoft.public.dotnet.framework.aspnet:185762
| >| >>>| X-Tomcat-NG:
| microsoft.public.dotnet.framework.aspnet
| >| >>>|
| >| >>>| If you read what I wrote, I don't need any clean
| up
| >| at
| >| >>Session End, but
| >| >>>| at "Page End" within the same session, long before
| >| >>Session End.
| >| >>>|
| >| >>>| In other words, there should've been a Page_Leave-
| >| >>event. In lack of this,
| >| >>>| what is the
| >| >>>| best way to handle clean up in Session when going
| >| from
| >| >>one page to another
| >| >>>| in a
| >| >>>| Web App, whithin a Session ?
| >| >>>|
| >| >>>| -H
| >| >>>|
| >| message
| >| >>>| | >| >>>| > How about session end event in the
| global.asax....
| >| >>>| >
| >| >>message
| >| >>>| > | >| >>>| > > But I wonder what is the best way to clean up
| >| >>Session when going to
| >| >>>one
| >| >>>| > page
| >| >>>| > > from another ?
| >| >>>| > >
| >| >>>| > > Session is only taken care of by the garbage
| >| >>collector when the
| >| >>>Session
| >| >>>| > > itself is dead, hence
| >| >>>| > > the session can carry a lot of unecesarry
| stuff
| >| >for
| >| >>a long time, and
| >| >>>| this
| >| >>>| > is
| >| >>>| > > causing the web app to be reset
| >| >>>| > > when the whole application is using to much
| >| memory.
| >| >>>| > >
| >| >>>| > > -H
| >| >>>| > >
| in
| >| >>message
| >| >>>| > > | >| >>>| > > > Ya me too, being new wanted to do a lot of
| >| >>cleanup, but found that
| >| >>>| > > sometimes
| >| >>>| > > > the garbage collector had paid a visit
| before
| >| >>unload fires.
| >| >>>| > > >
| in
| >| >>message
| >| >>>| > > > | (e-mail address removed)...
| >| >>>| > > > > Hi !
| >| >>>| > > > >
| >| >>>| > > > > I have a Wep App in C#.
| >| >>>| > > > > Page_Unload fires after Page_Load, and
| >| >>>| > > > > it seems totally unreasonable when you
| want
| >| to
| >| >>use this event when
| >| >>>| you
| >| >>>| > > > > _leave_ the page.
| >| >>>| > > > >
| >| >>>| > > > > In my project we wanted to use the
| >| >Page_Unload -
| >| >> event to clean up
| >| >>>| the
| >| >>>| > > > > Session variables, but
| >| >>>| > > > > when it turns out that it fires before the
| >| >end,
| >| >>it screws up the
| >| >>>| code,
| >| >>>| > > and
| >| >>>| > > > > we get NullPointerExceptions.
| >| >>>| > > > >
| >| >>>| > > > > Anyone ?
| >| >>>| > > > >
| >| >>>| > > > > Regards,
| >| >>>| > > > > Heidi
| >| >>>| > > > >
| >| >>>| > > > > (e-mail address removed)
| >| >>>| > > > >
| >| >>>| > > > >
| >| >>>| > > >
| >| >>>| > > >
| >| >>>| > >
| >| >>>| > >
| >| >>>| >
| >| >>>| >
| >| >>>|
| >| >>>|
| >| >>>|
| >| >>>
| >| >>>.
| >| >>>
| >| >>.
| >| >>
| >| >.
| >| >
| >|
| >
| >.
| >
|
 
J

Jeffrey Tan[MSFT]

Hi ,

Does my new solution resolve your problem?
If you still have any question, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| References: <#[email protected]>
<#[email protected]>
<#[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Page_Unload event fires to early
| Date: Fri, 31 Oct 2003 01:56:51 -0800
| Lines: 298
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: quoted-printable
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOflU5lVhkMS6U7QaaVl6R6SJIhOQ==
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:187752
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I'll try to explain more accurately. The Wep App has a
| menu which is written in a div-tag, like
| <div>
| <a href="http://myurl/newPage.aspx">New Page</a>
| </div>
| When you use this menu in order to go from the current
| page to New Page, the unload event is fired. The unload
| event posts to the server, hence the menu-choice isn't
| happening. Current page stays, no New Page.
| See ?
| There are different Session variables to clean up
| depending on each page, hence the clean is not easily
| generalized, and posting to a delsesssion.aspx between
| each page change seems to be too much just for a
| few "nulls".
| I just want a solution where the session cleanup is on the
| server side (aspx.cs) of each aspx-page with the
| possibility to navigate using the div-menu.
| Regards,
| Heidi
| >-----Original Message-----
| >
| >Hi ,
| >
| >Thanks for your feedback.
| >I do not quite understand what your "when the unload-
| event submits to the
| >server, the processing stops with this.The client change
| of page is not
| >valid anymore." means.
| >In my logic, I think you should handle in the client
| unload event,(Just as
| >you original find out), then submit to a delsesssion.aspx
| page. In the
| >delsesssion.aspx page's load event(server side), you can
| do your customized
| >session variables deletion. Finaly, delsesssion.aspx
| should use
| >RegisterClientScriptBlock method to generate a client
| script to client side
| >to close this page.
| >That is delsession.aspx's only purpose is delete the
| unwanted session
| >variables and close itself at once.
| >
| >If you still have anything unclear, please feel free to
| tell me.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><[email protected]>
| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><[email protected]>
| >| References: <#[email protected]>
| ><#[email protected]>
| ><#[email protected]>
| ><[email protected]>
| ><#[email protected]>
| ><[email protected]>
| ><[email protected]>
| ><[email protected]>
| >| Subject: Re: Page_Unload event fires to early
| >| Date: Thu, 30 Oct 2003 07:18:23 -0800
| >| Lines: 191
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: quoted-printable
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcOe+Q92PAYlcl7KQwyi0C245QElHg==
| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet:187546
| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| >|
| >| No, it is not that simple after all.
| >| When you want to change page in the Web App, you use a
| >| menu to go to a new url, but when the unload-event
| >| submits to the server, the processing stops with this.
| >| The client change of page is not valid anymore.
| >| ....
| >| Any good advice ?
| >| -Heidi
| >| >-----Original Message-----
| >| >
| >| >I figured it out, so now I have a method:
| >| >
| >| >I have a hidden value in the form:
| >| ><input type="hidden" name="action" value="" />
| >| >
| >| >On body onunload, I submit,
| >| >Form1.action.value = 'TidySession';
| >| >Form1.submit();
| >| >
| >| >In Page_Load, I check the value:
| >| >if( Request.Form["action"] == "TidySession" ){
| >| >
| >| > //Tidy Session
| >| >
| >| >I guess this will work whenever leaving a page.
| >| >
| >| >-H
| >| >
| >| >
| >| >
| >| >>-----Original Message-----
| >| >>Hi !
| >| >>
| >| >>I haven't had time to try it out, but I am also not
| sure
| >| >>how to do it.
| >| >>Do you have an example on how to do this, how to
| >| >>submit a request to the server side from javascript
| >| >>using the unload-event ?
| >| >>
| >| >>
| >| >>Regards,
| >| >>Heidi
| >| >>
| >| >>>-----Original Message-----
| >| >>>
| >| >>>Hi Heidi,
| >| >>>
| >| >>>Does my suggestion resolve your problem?
| >| >>>If you still have anything unclear, please feel free
| to
| >| >>let me known.
| >| >>>
| >| >>>Best regards,
| >| >>>Jeffrey Tan
| >| >>>Microsoft Online Partner Support
| >| >>>Get Secure! - www.microsoft.com/security
| >| >>>This posting is provided "as is" with no warranties
| and
| >| >>confers no rights.
| >| >>>
| >| >>>--------------------
| >| >>>| From: "Heidi Hundåla" <[email protected]>
| >| >>>| References:
| <#[email protected]>
| >| >>><#[email protected]>
| >| >>><#[email protected]>
| >| >>><[email protected]>
| >| >>>| Subject: Re: Page_Unload event fires to early
| >| >>>| Date: Wed, 22 Oct 2003 15:21:13 +0200
| >| >>>| Lines: 71
| >| >>>| X-Priority: 3
| >| >>>| X-MSMail-Priority: Normal
| >| >>>| X-Newsreader: Microsoft Outlook Express
| 6.00.2800.1158
| >| >>>| X-MimeOLE: Produced By Microsoft MimeOLE
| >| >V6.00.2800.1165
| >| >>>| Message-ID: <#[email protected]>
| >| >>>| Newsgroups:
| microsoft.public.dotnet.framework.aspnet
| >| >>>| NNTP-Posting-Host: 160.67.143.13
| >| >>>| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!
| >| >>TK2MSFTNGP10.phx.gbl
| >| >>>| Xref: cpmsftngxa06.phx.gbl
| >| >>microsoft.public.dotnet.framework.aspnet:185762
| >| >>>| X-Tomcat-NG:
| microsoft.public.dotnet.framework.aspnet
| >| >>>|
| >| >>>| If you read what I wrote, I don't need any clean
| up
| >| at
| >| >>Session End, but
| >| >>>| at "Page End" within the same session, long before
| >| >>Session End.
| >| >>>|
| >| >>>| In other words, there should've been a Page_Leave-
| >| >>event. In lack of this,
| >| >>>| what is the
| >| >>>| best way to handle clean up in Session when going
| >| from
| >| >>one page to another
| >| >>>| in a
| >| >>>| Web App, whithin a Session ?
| >| >>>|
| >| >>>| -H
| >| >>>|
| >| message
| >| >>>| | >| >>>| > How about session end event in the
| global.asax....
| >| >>>| >
| >| >>message
| >| >>>| > | >| >>>| > > But I wonder what is the best way to clean up
| >| >>Session when going to
| >| >>>one
| >| >>>| > page
| >| >>>| > > from another ?
| >| >>>| > >
| >| >>>| > > Session is only taken care of by the garbage
| >| >>collector when the
| >| >>>Session
| >| >>>| > > itself is dead, hence
| >| >>>| > > the session can carry a lot of unecesarry
| stuff
| >| >for
| >| >>a long time, and
| >| >>>| this
| >| >>>| > is
| >| >>>| > > causing the web app to be reset
| >| >>>| > > when the whole application is using to much
| >| memory.
| >| >>>| > >
| >| >>>| > > -H
| >| >>>| > >
| in
| >| >>message
| >| >>>| > > | >| >>>| > > > Ya me too, being new wanted to do a lot of
| >| >>cleanup, but found that
| >| >>>| > > sometimes
| >| >>>| > > > the garbage collector had paid a visit
| before
| >| >>unload fires.
| >| >>>| > > >
| in
| >| >>message
| >| >>>| > > > | (e-mail address removed)...
| >| >>>| > > > > Hi !
| >| >>>| > > > >
| >| >>>| > > > > I have a Wep App in C#.
| >| >>>| > > > > Page_Unload fires after Page_Load, and
| >| >>>| > > > > it seems totally unreasonable when you
| want
| >| to
| >| >>use this event when
| >| >>>| you
| >| >>>| > > > > _leave_ the page.
| >| >>>| > > > >
| >| >>>| > > > > In my project we wanted to use the
| >| >Page_Unload -
| >| >> event to clean up
| >| >>>| the
| >| >>>| > > > > Session variables, but
| >| >>>| > > > > when it turns out that it fires before the
| >| >end,
| >| >>it screws up the
| >| >>>| code,
| >| >>>| > > and
| >| >>>| > > > > we get NullPointerExceptions.
| >| >>>| > > > >
| >| >>>| > > > > Anyone ?
| >| >>>| > > > >
| >| >>>| > > > > Regards,
| >| >>>| > > > > Heidi
| >| >>>| > > > >
| >| >>>| > > > > (e-mail address removed)
| >| >>>| > > > >
| >| >>>| > > > >
| >| >>>| > > >
| >| >>>| > > >
| >| >>>| > >
| >| >>>| > >
| >| >>>| >
| >| >>>| >
| >| >>>|
| >| >>>|
| >| >>>|
| >| >>>
| >| >>>.
| >| >>>
| >| >>.
| >| >>
| >| >.
| >| >
| >|
| >
| >.
| >
|
 
K

keyur shah

If you are talking about the server codeit makes sense that it executes
load and then unload... anyway on the server side... the server once
done loading the page... returning html back to client, has nothing to
do but to clean up stuff.. and thats what unload will do...

I think u are seeking for some client-side solution.

Keyur Shah
Verizon Communications
732-423-0745
 
?

=?iso-8859-1?Q?Heidi_Hund=E5la?=

Hi

When I debugged, the page is submitted to the server
because of the unload event and the script which submits,
but maybe there is just a misunderstanding between us
regarding what is actually done.

Anyway, your suggestion on
2) ..you can use server side link button..
That is what I am trying to avoid, since the menu-
structure already is made in the "div"-way, and the rest
of the pages relate to it.
1) If you close the IE page, open another IE page and
visit the server. Then you can check the cookie's session
id(it will differ).
I don't quite understand, close the page ?

-H



-----Original Message-----

Hi ,

I have done some research for you. I find that there is some problem before
your issue.
I find that the onunload client script event can not submit form to a page.
I think when the client onunload event fires, the form has been destroyed,
so the form can not be submited. Code like this:
<script language="javascript">
function notifythepage()
{
alert("method called!");
document.Form1.submit();
}
<body onunload="notifythepage()">
</script>
<form name="Form1" method="post" action="delsession.aspx">
</form>
</body>

When you close the page, the alert("method called!"); will be called which
means the method is called while the onunload event.
But the delsession.aspx did not get called. which means the Form1 did not
submit to the delsession.aspx.

So I am thinking of another way of workaround.
1. If you close the IE page, open another IE page and visit the server.
Then you can check the cookie's session id(it will differ). So you can
remove some session variables.
2. If you use link navigate to another page, you can use server side link
button, and it will notify the server, then you can get the notify and
remove some session variables.

If you have anything unclear, please feel free to let me know.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| References: <#[email protected]>
<#[email protected]>
<#[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Page_Unload event fires to early
| Date: Fri, 31 Oct 2003 01:56:51 -0800
| Lines: 298
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: quoted-printable
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOflU5lVhkMS6U7QaaVl6R6SJIhOQ==
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:187752
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I'll try to explain more accurately. The Wep App has a
| menu which is written in a div-tag, like
| <div>
| <a href="http://myurl/newPage.aspx">New Page</a>
| </div>
| When you use this menu in order to go from the current
| page to New Page, the unload event is fired. The unload
| event posts to the server, hence the menu-choice isn't
| happening. Current page stays, no New Page.
| See ?
| There are different Session variables to clean up
| depending on each page, hence the clean is not easily
| generalized, and posting to a delsesssion.aspx between
| each page change seems to be too much just for a
| few "nulls".
| I just want a solution where the session cleanup is on the
| server side (aspx.cs) of each aspx-page with the
| possibility to navigate using the div-menu.
| Regards,
| Heidi
| >-----Original Message-----
| >
| >Hi ,
| >
| >Thanks for your feedback.
| >I do not quite understand what your "when the unload-
| event submits to the
| >server, the processing stops with this.The client change
| of page is not
| >valid anymore." means.
| >In my logic, I think you should handle in the client
| unload event,(Just as
| >you original find out), then submit to a delsesssion.aspx
| page. In the
| >delsesssion.aspx page's load event(server side), you can
| do your customized
| >session variables deletion. Finaly, delsesssion.aspx
| should use
| >RegisterClientScriptBlock method to generate a client
| script to client side
| >to close this page.
| >That is delsession.aspx's only purpose is delete the
| unwanted session
| >variables and close itself at once.
| >
| >If you still have anything unclear, please feel free to
| tell me.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><[email protected]>
| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><[email protected]>
| >| References: <#[email protected]>
| ><#[email protected]>
| ><#[email protected]>
| ><[email protected]>
| ><#[email protected]>
| ><[email protected]>
| ><[email protected]>
| ><[email protected]>
| >| Subject: Re: Page_Unload event fires to early
| >| Date: Thu, 30 Oct 2003 07:18:23 -0800
| >| Lines: 191
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: quoted-printable
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcOe+Q92PAYlcl7KQwyi0C245QElHg==
| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet:187546
| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| >|
| >| No, it is not that simple after all.
| >| When you want to change page in the Web App, you use
a
| >| menu to go to a new url, but when the unload-event
| >| submits to the server, the processing stops with this.
| >| The client change of page is not valid anymore.
| >| ....
| >| Any good advice ?
| >| -Heidi
| >| >-----Original Message-----
| >| >
| >| >I figured it out, so now I have a method:
| >| >
| >| >I have a hidden value in the form:
| >| ><input type="hidden" name="action" value="" />
| >| >
| >| >On body onunload, I submit,
| >| >Form1.action.value = 'TidySession';
| >| >Form1.submit();
| >| >
| >| >In Page_Load, I check the value:
| >| >if( Request.Form["action"] == "TidySession" ){
| >| >
| >| > //Tidy Session
| >| >
| >| >I guess this will work whenever leaving a page.
| >| >
| >| >-H
| >| >
| >| >
| >| >
| >| >>-----Original Message-----
| >| >>Hi !
| >| >>
| >| >>I haven't had time to try it out, but I am also not
| sure
| >| >>how to do it.
| >| >>Do you have an example on how to do this, how to
| >| >>submit a request to the server side from javascript
| >| >>using the unload-event ?
| >| >>
| >| >>
| >| >>Regards,
| >| >>Heidi
| >| >>
| >| >>>-----Original Message-----
| >| >>>
| >| >>>Hi Heidi,
| >| >>>
| >| >>>Does my suggestion resolve your problem?
| >| >>>If you still have anything unclear, please feel free
| to
| >| >>let me known.
| >| >>>
| >| >>>Best regards,
| >| >>>Jeffrey Tan
| >| >>>Microsoft Online Partner Support
| >| >>>Get Secure! - www.microsoft.com/security
| >| >>>This posting is provided "as is" with no warranties
| and
| >| >>confers no rights.
| >| >>>
| >| >>>--------------------
| >| >>>| From: "Heidi Hundåla" <[email protected]>
| >| >>>| References:
| <#[email protected]>
| >| >>><#[email protected]>
| >| >>><#[email protected]>
| >| >>><[email protected]>
| >| >>>| Subject: Re: Page_Unload event fires to early
| >| >>>| Date: Wed, 22 Oct 2003 15:21:13 +0200
| >| >>>| Lines: 71
| >| >>>| X-Priority: 3
| >| >>>| X-MSMail-Priority: Normal
| >| >>>| X-Newsreader: Microsoft Outlook Express
| 6.00.2800.1158
| >| >>>| X-MimeOLE: Produced By Microsoft MimeOLE
| >| >V6.00.2800.1165
| >| >>>| Message-ID:
 
J

Jeffrey Tan[MSFT]

Hi ,

I think this solution is not very well, it is hard to get the cookie's
session id.
I still think my original suggestion of using delsession.aspx to delete the
session variables more suitable.
In your page's client unload event, you should use window.showModalDialog()
to open the delsession.aspx.
In this page, you can handle the server side load event and del some
session variables. Then use RegisterClientScriptBlock to write the
"window.close" method to the client side. letting the page close itself.

And if you click link to navigate to another page, the client unload event
will also fire. So the session variables will also be deleted.

Btw: the page opened by window.open() will pop up a comfirm dialog, so I
suggest you use window.showModalDialog().

I have tried this logic, the delsession.aspx page will open and closed
almost at once, so the user will not notice of this page.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<[email protected]>
| References: <#[email protected]>
<#[email protected]>
<#[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Page_Unload event fires to early
| Date: Fri, 7 Nov 2003 01:11:43 -0800
| Lines: 431
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: quoted-printable
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOlDymDASQy0fgfTtaIOq3t1Q0ryA==
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:189197
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi
| When I debugged, the page is submitted to the server
| because of the unload event and the script which submits,
| but maybe there is just a misunderstanding between us
| regarding what is actually done.
| Anyway, your suggestion on
| >2) ..you can use server side link button..
| That is what I am trying to avoid, since the menu-
| structure already is made in the "div"-way, and the rest
| of the pages relate to it.
| >1) If you close the IE page, open another IE page and
| >visit the server. Then you can check the cookie's session
| >id(it will differ).
| I don't quite understand, close the page ?
| -H
| >-----Original Message-----
| >
| >Hi ,
| >
| >I have done some research for you. I find that there is
| some problem before
| >your issue.
| >I find that the onunload client script event can not
| submit form to a page.
| >I think when the client onunload event fires, the form
| has been destroyed,
| >so the form can not be submited. Code like this:
| ><script language="javascript">
| > function notifythepage()
| > {
| > alert("method called!");
| > document.Form1.submit();
| > }
| ><body onunload="notifythepage()">
| ></script>
| ><form name="Form1" method="post" action="delsession.aspx">
| ></form>
| ></body>
| >
| >When you close the page, the alert("method called!");
| will be called which
| >means the method is called while the onunload event.
| >But the delsession.aspx did not get called. which means
| the Form1 did not
| >submit to the delsession.aspx.
| >
| >So I am thinking of another way of workaround.
| >1. If you close the IE page, open another IE page and
| visit the server.
| >Then you can check the cookie's session id(it will
| differ). So you can
| >remove some session variables.
| >2. If you use link navigate to another page, you can use
| server side link
| >button, and it will notify the server, then you can get
| the notify and
| >remove some session variables.
| >
| >If you have anything unclear, please feel free to let me
| know.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><[email protected]>
| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><[email protected]>
| >| References: <#[email protected]>
| ><#[email protected]>
| ><#[email protected]>
| ><[email protected]>
| ><#[email protected]>
| ><[email protected]>
| ><[email protected]>
| ><[email protected]>
| ><[email protected]>
| ><[email protected]>
| >| Subject: Re: Page_Unload event fires to early
| >| Date: Fri, 31 Oct 2003 01:56:51 -0800
| >| Lines: 298
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: quoted-printable
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcOflU5lVhkMS6U7QaaVl6R6SJIhOQ==
| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet:187752
| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| >|
| >| I'll try to explain more accurately. The Wep App has a
| >| menu which is written in a div-tag, like
| >| <div>
| >| <a href="http://myurl/newPage.aspx">New Page</a>
| >| </div>
| >| When you use this menu in order to go from the current
| >| page to New Page, the unload event is fired. The unload
| >| event posts to the server, hence the menu-choice isn't
| >| happening. Current page stays, no New Page.
| >| See ?
| >| There are different Session variables to clean up
| >| depending on each page, hence the clean is not easily
| >| generalized, and posting to a delsesssion.aspx between
| >| each page change seems to be too much just for a
| >| few "nulls".
| >| I just want a solution where the session cleanup is on
| the
| >| server side (aspx.cs) of each aspx-page with the
| >| possibility to navigate using the div-menu.
| >| Regards,
| >| Heidi
| >| >-----Original Message-----
| >| >
| >| >Hi ,
| >| >
| >| >Thanks for your feedback.
| >| >I do not quite understand what your "when the unload-
| >| event submits to the
| >| >server, the processing stops with this.The client
| change
| >| of page is not
| >| >valid anymore." means.
| >| >In my logic, I think you should handle in the client
| >| unload event,(Just as
| >| >you original find out), then submit to a
| delsesssion.aspx
| >| page. In the
| >| >delsesssion.aspx page's load event(server side), you
| can
| >| do your customized
| >| >session variables deletion. Finaly, delsesssion.aspx
| >| should use
| >| >RegisterClientScriptBlock method to generate a client
| >| script to client side
| >| >to close this page.
| >| >That is delsession.aspx's only purpose is delete the
| >| unwanted session
| >| >variables and close itself at once.
| >| >
| >| >If you still have anything unclear, please feel free
| to
| >| tell me.
| >| >
| >| >Best regards,
| >| >Jeffrey Tan
| >| >Microsoft Online Partner Support
| >| >Get Secure! - www.microsoft.com/security
| >| >This posting is provided "as is" with no warranties
| and
| >| confers no rights.
| >| >
| >| >--------------------
| >| >| Content-Class: urn:content-classes:message
| >| >| From: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| >| ><[email protected]>
| >| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| >| ><[email protected]>
| >| >| References: <#[email protected]>
| >| ><#[email protected]>
| >| ><#[email protected]>
| >| ><[email protected]>
| >| ><#[email protected]>
| >| ><[email protected]>
| >| ><[email protected]>
| >| ><[email protected]>
| >| >| Subject: Re: Page_Unload event fires to early
| >| >| Date: Thu, 30 Oct 2003 07:18:23 -0800
| >| >| Lines: 191
| >| >| Message-ID: <[email protected]>
| >| >| MIME-Version: 1.0
| >| >| Content-Type: text/plain;
| >| >| charset="iso-8859-1"
| >| >| Content-Transfer-Encoding: quoted-printable
| >| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| >| Thread-Index: AcOe+Q92PAYlcl7KQwyi0C245QElHg==
| >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
| >| >| Path: cpmsftngxa06.phx.gbl
| >| >| Xref: cpmsftngxa06.phx.gbl
| >| microsoft.public.dotnet.framework.aspnet:187546
| >| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| >| >|
| >| >| No, it is not that simple after all.
| >| >| When you want to change page in the Web App, you use
| a
| >| >| menu to go to a new url, but when the unload-event
| >| >| submits to the server, the processing stops with
| this.
| >| >| The client change of page is not valid anymore.
| >| >| ....
| >| >| Any good advice ?
| >| >| -Heidi
| >| >| >-----Original Message-----
| >| >| >
| >| >| >I figured it out, so now I have a method:
| >| >| >
| >| >| >I have a hidden value in the form:
| >| >| ><input type="hidden" name="action" value="" />
| >| >| >
| >| >| >On body onunload, I submit,
| >| >| >Form1.action.value = 'TidySession';
| >| >| >Form1.submit();
| >| >| >
| >| >| >In Page_Load, I check the value:
| >| >| >if( Request.Form["action"] == "TidySession" ){
| >| >| >
| >| >| > //Tidy Session
| >| >| >
| >| >| >I guess this will work whenever leaving a page.
| >| >| >
| >| >| >-H
| >| >| >
| >| >| >
| >| >| >
| >| >| >>-----Original Message-----
| >| >| >>Hi !
| >| >| >>
| >| >| >>I haven't had time to try it out, but I am also
| not
| >| sure
| >| >| >>how to do it.
| >| >| >>Do you have an example on how to do this, how to
| >| >| >>submit a request to the server side from javascript
| >| >| >>using the unload-event ?
| >| >| >>
| >| >| >>
| >| >| >>Regards,
| >| >| >>Heidi
| >| >| >>
| >| >| >>>-----Original Message-----
| >| >| >>>
| >| >| >>>Hi Heidi,
| >| >| >>>
| >| >| >>>Does my suggestion resolve your problem?
| >| >| >>>If you still have anything unclear, please feel
| free
| >| to
| >| >| >>let me known.
| >| >| >>>
| >| >| >>>Best regards,
| >| >| >>>Jeffrey Tan
| >| >| >>>Microsoft Online Partner Support
| >| >| >>>Get Secure! - www.microsoft.com/security
| >| >| >>>This posting is provided "as is" with no
| warranties
| >| and
| >| >| >>confers no rights.
| >| >| >>>
| >| >| >>>--------------------
| >| >| >>>| From: "Heidi Hundåla" <[email protected]>
| >| >| >>>| References:
| >| <#[email protected]>
| >| >| >>><#[email protected]>
| >| >| >>><#[email protected]>
| >| >| >>><[email protected]>
| >| >| >>>| Subject: Re: Page_Unload event fires to early
| >| >| >>>| Date: Wed, 22 Oct 2003 15:21:13 +0200
| >| >| >>>| Lines: 71
| >| >| >>>| X-Priority: 3
| >| >| >>>| X-MSMail-Priority: Normal
| >| >| >>>| X-Newsreader: Microsoft Outlook Express
| >| 6.00.2800.1158
| >| >| >>>| X-MimeOLE: Produced By Microsoft MimeOLE
| >| >| >V6.00.2800.1165
| >| >| >>>| Message-ID:
| <#[email protected]>
| >| >| >>>| Newsgroups:
| >| microsoft.public.dotnet.framework.aspnet
| >| >| >>>| NNTP-Posting-Host: 160.67.143.13
| >| >| >>>| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!
| >| >| >>TK2MSFTNGP10.phx.gbl
| >| >| >>>| Xref: cpmsftngxa06.phx.gbl
| >| >| >>microsoft.public.dotnet.framework.aspnet:185762
| >| >| >>>| X-Tomcat-NG:
| >| microsoft.public.dotnet.framework.aspnet
| >| >| >>>|
| >| >| >>>| If you read what I wrote, I don't need any
| clean
| >| up
| >| >| at
| >| >| >>Session End, but
| >| >| >>>| at "Page End" within the same session, long
| before
| >| >| >>Session End.
| >| >| >>>|
| >| >| >>>| In other words, there should've been a
| Page_Leave-
| >| >| >>event. In lack of this,
| >| >| >>>| what is the
| >| >| >>>| best way to handle clean up in Session when
| going
| >| >| from
| >| >| >>one page to another
| >| >| >>>| in a
| >| >| >>>| Web App, whithin a Session ?
| >| >| >>>|
| >| >| >>>| -H
| >| >| >>>|
| >| >| message
| >| >| >>>| | >| >| >>>| > How about session end event in the
| >| global.asax....
| >| >| >>>| >
| in
| >| >| >>message
| >| >| >>>| > | (e-mail address removed)...
| >| >| >>>| > > But I wonder what is the best way to clean
| up
| >| >| >>Session when going to
| >| >| >>>one
| >| >| >>>| > page
| >| >| >>>| > > from another ?
| >| >| >>>| > >
| >| >| >>>| > > Session is only taken care of by the
| garbage
| >| >| >>collector when the
| >| >| >>>Session
| >| >| >>>| > > itself is dead, hence
| >| >| >>>| > > the session can carry a lot of unecesarry
| >| stuff
| >| >| >for
| >| >| >>a long time, and
| >| >| >>>| this
| >| >| >>>| > is
| >| >| >>>| > > causing the web app to be reset
| >| >| >>>| > > when the whole application is using to much
| >| >| memory.
| >| >| >>>| > >
| >| >| >>>| > > -H
| >| >| >>>| > >
| >| >| >>>| > > "Rajesh.V" <[email protected]>
| wrote
| >| in
| >| >| >>message
| >| >| >>>| > > | (e-mail address removed)...
| >| >| >>>| > > > Ya me too, being new wanted to do a lot
| of
| >| >| >>cleanup, but found that
| >| >| >>>| > > sometimes
| >| >| >>>| > > > the garbage collector had paid a visit
| >| before
| >| >| >>unload fires.
| >| >| >>>| > > >
| >| >| >>>| > > > "Heidi Hundåla" <[email protected]>
| wrote
| >| in
| >| >| >>message
| >| >| >>>| > > > | >| (e-mail address removed)...
| >| >| >>>| > > > > Hi !
| >| >| >>>| > > > >
| >| >| >>>| > > > > I have a Wep App in C#.
| >| >| >>>| > > > > Page_Unload fires after Page_Load, and
| >| >| >>>| > > > > it seems totally unreasonable when you
| >| want
| >| >| to
| >| >| >>use this event when
| >| >| >>>| you
| >| >| >>>| > > > > _leave_ the page.
| >| >| >>>| > > > >
| >| >| >>>| > > > > In my project we wanted to use the
| >| >| >Page_Unload -
| >| >| >> event to clean up
| >| >| >>>| the
| >| >| >>>| > > > > Session variables, but
| >| >| >>>| > > > > when it turns out that it fires before
| the
| >| >| >end,
| >| >| >>it screws up the
| >| >| >>>| code,
| >| >| >>>| > > and
| >| >| >>>| > > > > we get NullPointerExceptions.
| >| >| >>>| > > > >
| >| >| >>>| > > > > Anyone ?
| >| >| >>>| > > > >
| >| >| >>>| > > > > Regards,
| >| >| >>>| > > > > Heidi
| >| >| >>>| > > > >
| >| >| >>>| > > > > (e-mail address removed)
| >| >| >>>| > > > >
| >| >| >>>| > > > >
| >| >| >>>| > > >
| >| >| >>>| > > >
| >| >| >>>| > >
| >| >| >>>| > >
| >| >| >>>| >
| >| >| >>>| >
| >| >| >>>|
| >| >| >>>|
| >| >| >>>|
| >| >| >>>
| >| >| >>>.
| >| >| >>>
| >| >| >>.
| >| >| >>
| >| >| >.
| >| >| >
| >| >|
| >| >
| >| >.
| >| >
| >|
| >
| >.
| >
|
 

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

Top