473,698 Members | 2,672 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Redire ct 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?

<Page_Unload, page 1>
private void Page_Unload(obj ect sender, EventArgs e)

Debug.WriteLine ("Page_Unloa d in UnloadTestPage1 ");
Debug.WriteLine ("var in UnloadTestPage1 's Page_Unload: " + var);
var = "second (reset on first Page_Unload)";

Page_Load in UnloadTestPage1
Button1_Click in UnloadTestPage1 ...Response.Red irect("UnloadTe stPage2.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_Load in UnloadTestPage2
Page_Unload in UnloadTestPage2

Page_Load in UnloadTestPage1
Button1_Click in UnloadTestPage1 ...Server.Trans fer("UnloadTest Page2.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 1704

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

Similar topics

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 Page_Unload(object sender, System.EventArgs e) { System.Diagnostics.Debug.WriteLine("closing");
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
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 mozilla, just IE. This is a big problem because the PDF can be 20+ MB in size and is causing some serious performance issues. Writing the PDF to the filesystem then a redirect is not an option. I was wondering if anybody has any input on how...
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, Larry
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 this: public class IPage : System.Web.UI.Page {
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 original records and if the user presses cancel button or just leaves the page without cancelling we...
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 problem. This is what happens: When page is loaded Page_Load Page_Unload
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 triggered twice. I have created a very simple test page that illustrates this behaviour. The problem does not occur under .NET 2.0. If you would examine the logfile.txt created by the page running under 1.1, you will notice two entries for unload...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.