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

Page_Unload event fires to early

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

he***********@nrk.no
Nov 17 '05 #1
19 3439
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" <he***********@nrk.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

he***********@nrk.no

Nov 17 '05 #2
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" <he***********@nrk.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

he***********@nrk.no

Nov 17 '05 #3
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" <Ra***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <he***********@nrk.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

he***********@nrk.no


Nov 17 '05 #4
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" <Ra***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <he***********@nrk.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

he***********@nrk.no


Nov 17 '05 #5
How about session end event in the global.asax....

"Heidi Hundåla" <he***********@nrk.no> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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" <Ra***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <he***********@nrk.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

he***********@nrk.no



Nov 17 '05 #6
How about session end event in the global.asax....

"Heidi Hundåla" <he***********@nrk.no> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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" <Ra***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <he***********@nrk.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

he***********@nrk.no



Nov 17 '05 #7
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

"Rajesh.V" <Ra***********@hotmail.com> wrote in message
news:Oh**************@TK2MSFTNGP10.phx.gbl...
How about session end event in the global.asax....

"Heidi Hundåla" <he***********@nrk.no> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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" <Ra***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <he***********@nrk.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> 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
>
> he***********@nrk.no
>
>



Nov 17 '05 #8
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

"Rajesh.V" <Ra***********@hotmail.com> wrote in message
news:Oh**************@TK2MSFTNGP10.phx.gbl...
How about session end event in the global.asax....

"Heidi Hundåla" <he***********@nrk.no> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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" <Ra***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <he***********@nrk.no> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> 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
>
> he***********@nrk.no
>
>



Nov 17 '05 #9

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" <he***********@nrk.no>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
| 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: <#5**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 160.67.143.13
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.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
|
| "Rajesh.V" <Ra***********@hotmail.com> wrote in message
| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| > How about session end event in the global.asax....
| >
| > "Heidi Hundåla" <he***********@nrk.no> wrote in message
| > news:%2****************@tk2msftngp13.phx.gbl...
| > > 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" <Ra***********@hotmail.com> wrote in message
| > > news:%2****************@TK2MSFTNGP10.phx.gbl...
| > > > 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" <he***********@nrk.no> wrote in message
| > > > news:%2****************@TK2MSFTNGP11.phx.gbl...
| > > > > 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
| > > > >
| > > > > he***********@nrk.no
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|

Nov 17 '05 #10

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" <he***********@nrk.no>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
| 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: <#5**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 160.67.143.13
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.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
|
| "Rajesh.V" <Ra***********@hotmail.com> wrote in message
| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| > How about session end event in the global.asax....
| >
| > "Heidi Hundåla" <he***********@nrk.no> wrote in message
| > news:%2****************@tk2msftngp13.phx.gbl...
| > > 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" <Ra***********@hotmail.com> wrote in message
| > > news:%2****************@TK2MSFTNGP10.phx.gbl...
| > > > 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" <he***********@nrk.no> wrote in message
| > > > news:%2****************@TK2MSFTNGP11.phx.gbl...
| > > > > 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
| > > > >
| > > > > he***********@nrk.no
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|

Nov 17 '05 #11

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" <he***********@nrk.no>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
| 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: <#5**************@TK2MSFTNGP10.phx.gbl>
| 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:18576 2
| 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
|
| "Rajesh.V" <Ra***********@hotmail.com> wrote in
message| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| > How about session end event in the global.asax....
| >
| > "Heidi Hundåla" <he***********@nrk.no> wrote in

message
| > news:%2****************@tk2msftngp13.phx.gbl...
| > > 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" <Ra***********@hotmail.com> wrote in

message
| > > news:%2****************@TK2MSFTNGP10.phx.gbl...
| > > > 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" <he***********@nrk.no> wrote in

message
| > > > news:%2****************@TK2MSFTNGP11.phx.gbl...
| > > > > 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
| > > > >
| > > > > he***********@nrk.no
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|

.

.

.

Nov 17 '05 #12

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?=
<an*******@discussions.microsoft.com>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<an*******@discussions.microsoft.com>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
<#5**************@TK2MSFTNGP10.phx.gbl>
<Xt**************@cpmsftngxa06.phx.gbl>
<01****************************@phx.gbl>
<0a****************************@phx.gbl>
| Subject: Re: Page_Unload event fires to early
| Date: Thu, 30 Oct 2003 07:18:23 -0800
| Lines: 191
| Message-ID: <0c****************************@phx.gbl>
| 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" <he***********@nrk.no>
| >>>| References: <#4**************@TK2MSFTNGP11.phx.gbl>
| >>><#b**************@TK2MSFTNGP10.phx.gbl>
| >>><#u**************@tk2msftngp13.phx.gbl>
| >>><Oh**************@TK2MSFTNGP10.phx.gbl>
| >>>| 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: <#5**************@TK2MSFTNGP10.phx.gbl>
| >>>| 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:18576 2
| >>>| 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
| >>>|
| >>>| "Rajesh.V" <Ra***********@hotmail.com> wrote in
| message
| >>>| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| >>>| > How about session end event in the global.asax....
| >>>| >
| >>>| > "Heidi Hundåla" <he***********@nrk.no> wrote in
| >>message
| >>>| > news:%2****************@tk2msftngp13.phx.gbl...
| >>>| > > 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" <Ra***********@hotmail.com> wrote in
| >>message
| >>>| > > news:%2****************@TK2MSFTNGP10.phx.gbl...
| >>>| > > > 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" <he***********@nrk.no> wrote in
| >>message
| >>>| > > > news:%2****************@TK2MSFTNGP11.phx.gbl...
| >>>| > > > > 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
| >>>| > > > >
| >>>| > > > > he***********@nrk.no
| >>>| > > > >
| >>>| > > > >
| >>>| > > >
| >>>| > > >
| >>>| > >
| >>>| > >
| >>>| >
| >>>| >
| >>>|
| >>>|
| >>>|
| >>>
| >>>.
| >>>
| >>.
| >>
| >.
| >
|

Nov 17 '05 #13
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?=
<an*******@discussions.microsoft.com>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<an*******@discussions.microsoft.com>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
<#5**************@TK2MSFTNGP10.phx.gbl>
<Xt**************@cpmsftngxa06.phx.gbl>
<01****************************@phx.gbl>
<0a****************************@phx.gbl>
| Subject: Re: Page_Unload event fires to early
| Date: Thu, 30 Oct 2003 07:18:23 -0800
| Lines: 191
| Message-ID: <0c****************************@phx.gbl>
| 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" <he***********@nrk.no>
| >>>| References: <#4**************@TK2MSFTNGP11.phx.gbl> | >>><#b**************@TK2MSFTNGP10.phx.gbl>
| >>><#u**************@tk2msftngp13.phx.gbl>
| >>><Oh**************@TK2MSFTNGP10.phx.gbl>
| >>>| 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: <#5**************@TK2MSFTNGP10.phx.gbl>
| >>>| 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:18576 2
| >>>| 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
| >>>|
| >>>| "Rajesh.V" <Ra***********@hotmail.com> wrote in
| message
| >>>| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| >>>| > How about session end event in the global.asax....| >>>| >
| >>>| > "Heidi Hundåla" <he***********@nrk.no> wrote in
| >>message
| >>>| > news:%2****************@tk2msftngp13.phx.gbl...
| >>>| > > 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" <Ra***********@hotmail.com> wrote in | >>message
| >>>| > > news:%2****************@TK2MSFTNGP10.phx.gbl...
| >>>| > > > 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" <he***********@nrk.no> wrote in | >>message
| >>>| > > > news:% 23***************@TK2MSFTNGP11.phx.gbl...| >>>| > > > > 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
| >>>| > > > >
| >>>| > > > > he***********@nrk.no
| >>>| > > > >
| >>>| > > > >
| >>>| > > >
| >>>| > > >
| >>>| > >
| >>>| > >
| >>>| >
| >>>| >
| >>>|
| >>>|
| >>>|
| >>>
| >>>.
| >>>
| >>.
| >>
| >.
| >
|

.

Nov 17 '05 #14

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?=
<an*******@discussions.microsoft.com>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<an*******@discussions.microsoft.com>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
<#5**************@TK2MSFTNGP10.phx.gbl>
<Xt**************@cpmsftngxa06.phx.gbl>
<01****************************@phx.gbl>
<0a****************************@phx.gbl>
<0c****************************@phx.gbl>
<fj**************@cpmsftngxa06.phx.gbl>
| Subject: Re: Page_Unload event fires to early
| Date: Fri, 31 Oct 2003 01:56:51 -0800
| Lines: 298
| Message-ID: <02****************************@phx.gbl>
| 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?=
| ><an*******@discussions.microsoft.com>
| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><an*******@discussions.microsoft.com>
| >| References: <#4**************@TK2MSFTNGP11.phx.gbl>
| ><#b**************@TK2MSFTNGP10.phx.gbl>
| ><#u**************@tk2msftngp13.phx.gbl>
| ><Oh**************@TK2MSFTNGP10.phx.gbl>
| ><#5**************@TK2MSFTNGP10.phx.gbl>
| ><Xt**************@cpmsftngxa06.phx.gbl>
| ><01****************************@phx.gbl>
| ><0a****************************@phx.gbl>
| >| Subject: Re: Page_Unload event fires to early
| >| Date: Thu, 30 Oct 2003 07:18:23 -0800
| >| Lines: 191
| >| Message-ID: <0c****************************@phx.gbl>
| >| 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" <he***********@nrk.no>
| >| >>>| References:
| <#4**************@TK2MSFTNGP11.phx.gbl>
| >| >>><#b**************@TK2MSFTNGP10.phx.gbl>
| >| >>><#u**************@tk2msftngp13.phx.gbl>
| >| >>><Oh**************@TK2MSFTNGP10.phx.gbl>
| >| >>>| 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: <#5**************@TK2MSFTNGP10.phx.gbl>
| >| >>>| 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:18576 2
| >| >>>| 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
| >| >>>|
| >| >>>| "Rajesh.V" <Ra***********@hotmail.com> wrote in
| >| message
| >| >>>| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| >| >>>| > How about session end event in the
| global.asax....
| >| >>>| >
| >| >>>| > "Heidi Hundåla" <he***********@nrk.no> wrote in
| >| >>message
| >| >>>| > news:%2****************@tk2msftngp13.phx.gbl...
| >| >>>| > > 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" <Ra***********@hotmail.com> wrote
| in
| >| >>message
| >| >>>| > > news:%2****************@TK2MSFTNGP10.phx.gbl...
| >| >>>| > > > 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" <he***********@nrk.no> wrote
| in
| >| >>message
| >| >>>| > > > news:%
| 23***************@TK2MSFTNGP11.phx.gbl...
| >| >>>| > > > > 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
| >| >>>| > > > >
| >| >>>| > > > > he***********@nrk.no
| >| >>>| > > > >
| >| >>>| > > > >
| >| >>>| > > >
| >| >>>| > > >
| >| >>>| > >
| >| >>>| > >
| >| >>>| >
| >| >>>| >
| >| >>>|
| >| >>>|
| >| >>>|
| >| >>>
| >| >>>.
| >| >>>
| >| >>.
| >| >>
| >| >.
| >| >
| >|
| >
| >.
| >
|

Nov 17 '05 #15
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" <he***********@nrk.no>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
| 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: <#5**************@TK2MSFTNGP10.phx.gbl>
| 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
|
| "Rajesh.V" <Ra***********@hotmail.com> wrote in message
| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| > How about session end event in the global.asax....
| >
| > "Heidi Hundåla" <he***********@nrk.no> wrote in message| > news:%2****************@tk2msftngp13.phx.gbl...
| > > 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" <Ra***********@hotmail.com> wrote in message| > > news:%2****************@TK2MSFTNGP10.phx.gbl...
| > > > 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" <he***********@nrk.no> wrote in message| > > > news:%2****************@TK2MSFTNGP11.phx.gbl...
| > > > > 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
| > > > >
| > > > > he***********@nrk.no
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|

.

Nov 17 '05 #16

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?=
<an*******@discussions.microsoft.com>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<an*******@discussions.microsoft.com>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
<#5**************@TK2MSFTNGP10.phx.gbl>
<Xt**************@cpmsftngxa06.phx.gbl>
<01****************************@phx.gbl>
<0a****************************@phx.gbl>
<0c****************************@phx.gbl>
<fj**************@cpmsftngxa06.phx.gbl>
| Subject: Re: Page_Unload event fires to early
| Date: Fri, 31 Oct 2003 01:56:51 -0800
| Lines: 298
| Message-ID: <02****************************@phx.gbl>
| 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?=
| ><an*******@discussions.microsoft.com>
| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><an*******@discussions.microsoft.com>
| >| References: <#4**************@TK2MSFTNGP11.phx.gbl>
| ><#b**************@TK2MSFTNGP10.phx.gbl>
| ><#u**************@tk2msftngp13.phx.gbl>
| ><Oh**************@TK2MSFTNGP10.phx.gbl>
| ><#5**************@TK2MSFTNGP10.phx.gbl>
| ><Xt**************@cpmsftngxa06.phx.gbl>
| ><01****************************@phx.gbl>
| ><0a****************************@phx.gbl>
| >| Subject: Re: Page_Unload event fires to early
| >| Date: Thu, 30 Oct 2003 07:18:23 -0800
| >| Lines: 191
| >| Message-ID: <0c****************************@phx.gbl>
| >| 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" <he***********@nrk.no>
| >| >>>| References:
| <#4**************@TK2MSFTNGP11.phx.gbl>
| >| >>><#b**************@TK2MSFTNGP10.phx.gbl>
| >| >>><#u**************@tk2msftngp13.phx.gbl>
| >| >>><Oh**************@TK2MSFTNGP10.phx.gbl>
| >| >>>| 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: <#5**************@TK2MSFTNGP10.phx.gbl>
| >| >>>| 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:18576 2
| >| >>>| 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
| >| >>>|
| >| >>>| "Rajesh.V" <Ra***********@hotmail.com> wrote in
| >| message
| >| >>>| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| >| >>>| > How about session end event in the
| global.asax....
| >| >>>| >
| >| >>>| > "Heidi Hundåla" <he***********@nrk.no> wrote in
| >| >>message
| >| >>>| > news:%2****************@tk2msftngp13.phx.gbl...
| >| >>>| > > 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" <Ra***********@hotmail.com> wrote
| in
| >| >>message
| >| >>>| > > news:%2****************@TK2MSFTNGP10.phx.gbl...
| >| >>>| > > > 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" <he***********@nrk.no> wrote
| in
| >| >>message
| >| >>>| > > > news:%
| 23***************@TK2MSFTNGP11.phx.gbl...
| >| >>>| > > > > 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
| >| >>>| > > > >
| >| >>>| > > > > he***********@nrk.no
| >| >>>| > > > >
| >| >>>| > > > >
| >| >>>| > > >
| >| >>>| > > >
| >| >>>| > >
| >| >>>| > >
| >| >>>| >
| >| >>>| >
| >| >>>|
| >| >>>|
| >| >>>|
| >| >>>
| >| >>>.
| >| >>>
| >| >>.
| >| >>
| >| >.
| >| >
| >|
| >
| >.
| >
|

Nov 17 '05 #17
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #18
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?=
<an*******@discussions.microsoft.com>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<an*******@discussions.microsoft.com>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
<#5**************@TK2MSFTNGP10.phx.gbl>
<Xt**************@cpmsftngxa06.phx.gbl>
<01****************************@phx.gbl>
<0a****************************@phx.gbl>
<0c****************************@phx.gbl>
<fj**************@cpmsftngxa06.phx.gbl>
| Subject: Re: Page_Unload event fires to early
| Date: Fri, 31 Oct 2003 01:56:51 -0800
| Lines: 298
| Message-ID: <02****************************@phx.gbl>
| 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?=
| ><an*******@discussions.microsoft.com>
| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><an*******@discussions.microsoft.com>
| >| References: <#4**************@TK2MSFTNGP11.phx.gbl>
| ><#b**************@TK2MSFTNGP10.phx.gbl>
| ><#u**************@tk2msftngp13.phx.gbl>
| ><Oh**************@TK2MSFTNGP10.phx.gbl>
| ><#5**************@TK2MSFTNGP10.phx.gbl>
| ><Xt**************@cpmsftngxa06.phx.gbl>
| ><01****************************@phx.gbl>
| ><0a****************************@phx.gbl>
| >| Subject: Re: Page_Unload event fires to early
| >| Date: Thu, 30 Oct 2003 07:18:23 -0800
| >| Lines: 191
| >| Message-ID: <0c****************************@phx.gbl>
| >| 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" <he***********@nrk.no>
| >| >>>| References:
| <#4**************@TK2MSFTNGP11.phx.gbl>
| >| >>><#b**************@TK2MSFTNGP10.phx.gbl>
| >| >>><#u**************@tk2msftngp13.phx.gbl>
| >| >>><Oh**************@TK2MSFTNGP10.phx.gbl>
| >| >>>| 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: <#5**************@TK2MSFTNGP10.phx.gbl>| >| >>>| 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:18576 2
| >| >>>| 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
| >| >>>|
| >| >>>| "Rajesh.V" <Ra***********@hotmail.com> wrote in
| >| message
| >| >>>| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| >| >>>| > How about session end event in the
| global.asax....
| >| >>>| >
| >| >>>| > "Heidi Hundåla" <he***********@nrk.no> wrote in | >| >>message
| >| >>>| > news:% 23***************@tk2msftngp13.phx.gbl...| >| >>>| > > 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" <Ra***********@hotmail.com> wrote | in
| >| >>message
| >| >>>| > > news:% 23***************@TK2MSFTNGP10.phx.gbl...| >| >>>| > > > 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" <he***********@nrk.no> wrote | in
| >| >>message
| >| >>>| > > > news:%
| 23***************@TK2MSFTNGP11.phx.gbl...
| >| >>>| > > > > 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
| >| >>>| > > > >
| >| >>>| > > > > he***********@nrk.no
| >| >>>| > > > >
| >| >>>| > > > >
| >| >>>| > > >
| >| >>>| > > >
| >| >>>| > >
| >| >>>| > >
| >| >>>| >
| >| >>>| >
| >| >>>|
| >| >>>|
| >| >>>|
| >| >>>
| >| >>>.
| >| >>>
| >| >>.
| >| >>
| >| >.
| >| >
| >|
| >
| >.
| >
|

.

Nov 17 '05 #19

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?=
<an*******@discussions.microsoft.com>
| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
<an*******@discussions.microsoft.com>
| References: <#4**************@TK2MSFTNGP11.phx.gbl>
<#b**************@TK2MSFTNGP10.phx.gbl>
<#u**************@tk2msftngp13.phx.gbl>
<Oh**************@TK2MSFTNGP10.phx.gbl>
<#5**************@TK2MSFTNGP10.phx.gbl>
<Xt**************@cpmsftngxa06.phx.gbl>
<01****************************@phx.gbl>
<0a****************************@phx.gbl>
<0c****************************@phx.gbl>
<fj**************@cpmsftngxa06.phx.gbl>
<02****************************@phx.gbl>
<Mf**************@cpmsftngxa06.phx.gbl>
| Subject: Re: Page_Unload event fires to early
| Date: Fri, 7 Nov 2003 01:11:43 -0800
| Lines: 431
| Message-ID: <08****************************@phx.gbl>
| 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?=
| ><an*******@discussions.microsoft.com>
| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| ><an*******@discussions.microsoft.com>
| >| References: <#4**************@TK2MSFTNGP11.phx.gbl>
| ><#b**************@TK2MSFTNGP10.phx.gbl>
| ><#u**************@tk2msftngp13.phx.gbl>
| ><Oh**************@TK2MSFTNGP10.phx.gbl>
| ><#5**************@TK2MSFTNGP10.phx.gbl>
| ><Xt**************@cpmsftngxa06.phx.gbl>
| ><01****************************@phx.gbl>
| ><0a****************************@phx.gbl>
| ><0c****************************@phx.gbl>
| ><fj**************@cpmsftngxa06.phx.gbl>
| >| Subject: Re: Page_Unload event fires to early
| >| Date: Fri, 31 Oct 2003 01:56:51 -0800
| >| Lines: 298
| >| Message-ID: <02****************************@phx.gbl>
| >| 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?=
| >| ><an*******@discussions.microsoft.com>
| >| >| Sender: =?iso-8859-1?Q?Heidi_Hund=E5la?=
| >| ><an*******@discussions.microsoft.com>
| >| >| References: <#4**************@TK2MSFTNGP11.phx.gbl>
| >| ><#b**************@TK2MSFTNGP10.phx.gbl>
| >| ><#u**************@tk2msftngp13.phx.gbl>
| >| ><Oh**************@TK2MSFTNGP10.phx.gbl>
| >| ><#5**************@TK2MSFTNGP10.phx.gbl>
| >| ><Xt**************@cpmsftngxa06.phx.gbl>
| >| ><01****************************@phx.gbl>
| >| ><0a****************************@phx.gbl>
| >| >| Subject: Re: Page_Unload event fires to early
| >| >| Date: Thu, 30 Oct 2003 07:18:23 -0800
| >| >| Lines: 191
| >| >| Message-ID: <0c****************************@phx.gbl>
| >| >| 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" <he***********@nrk.no>
| >| >| >>>| References:
| >| <#4**************@TK2MSFTNGP11.phx.gbl>
| >| >| >>><#b**************@TK2MSFTNGP10.phx.gbl>
| >| >| >>><#u**************@tk2msftngp13.phx.gbl>
| >| >| >>><Oh**************@TK2MSFTNGP10.phx.gbl>
| >| >| >>>| 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:
| <#5**************@TK2MSFTNGP10.phx.gbl>
| >| >| >>>| 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:18576 2
| >| >| >>>| 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
| >| >| >>>|
| >| >| >>>| "Rajesh.V" <Ra***********@hotmail.com> wrote in
| >| >| message
| >| >| >>>| news:Oh**************@TK2MSFTNGP10.phx.gbl...
| >| >| >>>| > How about session end event in the
| >| global.asax....
| >| >| >>>| >
| >| >| >>>| > "Heidi Hundåla" <he***********@nrk.no> wrote
| in
| >| >| >>message
| >| >| >>>| > news:%
| 23***************@tk2msftngp13.phx.gbl...
| >| >| >>>| > > 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" <Ra***********@hotmail.com>
| wrote
| >| in
| >| >| >>message
| >| >| >>>| > > news:%
| 23***************@TK2MSFTNGP10.phx.gbl...
| >| >| >>>| > > > 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" <he***********@nrk.no>
| wrote
| >| in
| >| >| >>message
| >| >| >>>| > > > news:%
| >| 23***************@TK2MSFTNGP11.phx.gbl...
| >| >| >>>| > > > > 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
| >| >| >>>| > > > >
| >| >| >>>| > > > > he***********@nrk.no
| >| >| >>>| > > > >
| >| >| >>>| > > > >
| >| >| >>>| > > >
| >| >| >>>| > > >
| >| >| >>>| > >
| >| >| >>>| > >
| >| >| >>>| >
| >| >| >>>| >
| >| >| >>>|
| >| >| >>>|
| >| >| >>>|
| >| >| >>>
| >| >| >>>.
| >| >| >>>
| >| >| >>.
| >| >| >>
| >| >| >.
| >| >| >
| >| >|
| >| >
| >| >.
| >| >
| >|
| >
| >.
| >
|

Nov 17 '05 #20

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

Similar topics

0
by: tascien | last post by:
I found a use for Page_Unload event method... here is the scenario: 1. Page.aspx has DoStuff.ascx in it. 2. DoStuff.ascx has a button that updates child control label lbXml depending on user...
3
by: James Hawthorne | last post by:
Hi, I have created a asp.net web application and I hooked up page_unload so I can clean up some things when i close it down. The problem is, page_unload gets called when I first load the page, not...
1
by: Robert Scheer | last post by:
Hi. Debugging one of my pages I noticed that everytime I call the page, the first event to run is Page_Load and after it the Page_Unload. If I postback to the page the Page_Unload runs again....
0
by: Heidi Hundåla | last post by:
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...
4
by: Larry Morris | last post by:
The following code, pasted into a web form with a link button on it, will cause the page_unload event to fire twice. If I remove the response.redirect, the problem goes away :). I've got a work...
0
by: chefo | last post by:
Well, the subject describes my problem quite well :-) Here is some additional information. I use a common base class for all the pages in my project. It is derived from Page and it is not...
0
by: JeffM | last post by:
This seems odd, but it appears that the Page_Unload event is fired twice on a Response.Redirect or a Server.Transfer. The output below demonstrates that during the move from the first to the 2nd...
7
by: Cenk | last post by:
Hi, After converting my projects to ASP.Net 2.0 I have seen a problem with Page_unload. Ä°n framework 1.1 page_unload event fires when you are leaving the page or has closed the browser window....
5
by: =?Utf-8?B?Um9sYW5kcGlzaA==?= | last post by:
Hi there, I'm using Web Developer Express 2005 in my ASP.NET learning. I tried creating a simple aspx page using "code-behind" approach. I noticed that protected void Page_Load event method...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.