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

Page_Unload fires twice on Redirect or Transfer?

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 this?
Thanks,
Jeff

<Page_Unload, page 1>
private void Page_Unload(object sender, EventArgs e)
{

Debug.WriteLine("Page_Unload in UnloadTestPage1");
Debug.WriteLine("var in UnloadTestPage1's Page_Unload: " + var);
var = "second (reset on first Page_Unload)";
}
</>

<output>
RESPONSE.REDIRECT
Page_Load in UnloadTestPage1
Button1_Click in UnloadTestPage1...Response.Redirect("UnloadTestPag e2.aspx")
Page_Unload in UnloadTestPage1
var set in UnloadTestPage1's Page_Unload: "first (default)"
Page_Unload in UnloadTestPage1
var set in UnloadTestPage1's Page_Unload: "second (reset on first
Page_Unload)"
Page_Load in UnloadTestPage2
Page_Unload in UnloadTestPage2

SERVER.TRANSFER
Page_Load in UnloadTestPage1
Button1_Click in UnloadTestPage1...Server.Transfer("UnloadTestPage2 .aspx")
Page_Load in UnloadTestPage2
Page_Unload in UnloadTestPage2
Page_Unload in UnloadTestPage1
var set in UnloadTestPage1's Page_Unload: first (default)
Page_Unload in UnloadTestPage1
var set in UnloadTestPage1's Page_Unload: second (reset on first Page_Unload)
Mar 7 '06 #1
0 1680

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

Similar topics

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...
19
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...
7
by: Jay Douglas | last post by:
Hello all, I have a asp.net page that creates a pdf on the fly and sends the pdf down to the browser. When calling the page up in IE the Page_Load event is fried twice. This doesn't happen with...
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...
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....
0
by: Stina | last post by:
I have a problem with the Page_Unload event being called twice in a row on a redirect and I just can't figure out why. I have seen other threads on this subject but not found a solution to the...
2
by: Dan Lichiardopol | last post by:
Hi there! I'm trying to use page unload event in order to write info to a text file. Everything works fine, unless code contains a call to Response.End. Then, the unload event appears to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.