473,578 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 NullPointerExce ptions.

Anyone ?

Regards,
Heidi

he***********@n rk.no
Nov 17 '05 #1
19 3468
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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.

Anyone ?

Regards,
Heidi

he***********@n rk.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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.

Anyone ?

Regards,
Heidi

he***********@n rk.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******** ********@TK2MSF TNGP10.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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.

Anyone ?

Regards,
Heidi

he***********@n rk.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******** ********@TK2MSF TNGP10.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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.

Anyone ?

Regards,
Heidi

he***********@n rk.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******** ********@tk2msf tngp13.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******** ********@TK2MSF TNGP10.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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.

Anyone ?

Regards,
Heidi

he***********@n rk.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******** ********@tk2msf tngp13.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******** ********@TK2MSF TNGP10.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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.

Anyone ?

Regards,
Heidi

he***********@n rk.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******** ******@TK2MSFTN GP10.phx.gbl...
How about session end event in the global.asax....

"Heidi Hundåla" <he***********@ nrk.no> wrote in message
news:%2******** ********@tk2msf tngp13.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******** ********@TK2MSF TNGP10.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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.
>
> Anyone ?
>
> Regards,
> Heidi
>
> he***********@n rk.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******** ******@TK2MSFTN GP10.phx.gbl...
How about session end event in the global.asax....

"Heidi Hundåla" <he***********@ nrk.no> wrote in message
news:%2******** ********@tk2msf tngp13.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******** ********@TK2MSF TNGP10.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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.
>
> Anyone ?
>
> Regards,
> Heidi
>
> he***********@n rk.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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: 160.67.143.13
| Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1857 62
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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******** ******@TK2MSFTN GP10.phx.gbl...
| > How about session end event in the global.asax....
| >
| > "Heidi Hundåla" <he***********@ nrk.no> wrote in message
| > news:%2******** ********@tk2msf tngp13.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******** ********@TK2MSF TNGP10.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******** ********@TK2MSF TNGP11.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 NullPointerExce ptions.
| > > > >
| > > > > Anyone ?
| > > > >
| > > > > Regards,
| > > > > Heidi
| > > > >
| > > > > he***********@n rk.no
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|

Nov 17 '05 #10

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

Similar topics

0
1433
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 choices on input controls inside DoStuff.ascx. 3. But page.aspx, whats to know what is stored in lbXml so it can process its own logic. problem:
3
9987
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 when I close it. I know this because I put a breakpoint within the method, and it stops when i first run it, not when I close. private void...
1
15677
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. Shouldn't the Page_Unload event runs only when I close the page or submit the page? I can't understand why the Unload event runs when I load the page...
0
944
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 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
4
6081
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 around, but I'm curious how one is supposed to programmatically navigate between web pages without the page_unload event firing twice. Thanks, ...
0
1408
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 abstract, because there was some problem with the compilation. I define a common Page_Unload handler in the base class and subscribe for the event like...
0
1699
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 page, the event fires twice on the 1st page during Postback. The "var" set the first time is visible the 2nd time it fires. Anyone else notice...
7
2109
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. Now in 2.0 when you initally load the page Page_unload event fires after page_load event. In some of our aspx pages we craete some versions of...
5
15266
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 appears automatically in mypage.aspx.cs Ok, so far so good, but now I need to code something when Page_Unload occurs but I can't find a place to choose...
0
7847
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8125
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8290
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8148
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6522
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1113
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.