Page_Unload fires twice on Redirect or Transfer?

G

Guest

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("UnloadTestPage2.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)"

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top