Quick question : Is the Page_Unload() method always called? For instance, if I do a Server.Transfer() or Response.Redirect() to another page, is it still called? How about after an unhandled exception? Thanks in advance for any input!
It should always be called. See this article on MSDN for details: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconwebformspageprocessingstages.asp
Darrell Norton, MVP
Darrell Norton's Blog Please click "Mark as Answer" if this helped you.
General hint, turn the trace & page flag on in Web.config. You'll see all the events...or though in this case you'd have to be quick to spot it before the page was redirected ;)
Yeah, I did try that, but I guess I'm getting old because my reaction speeds aren't quite fast enough to read the trace in 0.00123 milliseconds :) In the end what I did do to finally satisfy myself was to create and write to a file in the Page_Unload() event
- if the file is created and written to then I know the event was called. It turns out that it IS called even after redirects and exceptions (which is what I thought but wanted to be 100% sure). Not elegant, but it works :)
Diplo
Member
160 Points
32 Posts
Is Page_Unload() *always* called?
Mar 22, 2004 10:37 PM|LINK
DarrellNorto...
All-Star
86665 Points
9634 Posts
Moderator
MVP
Re: Is Page_Unload() *always* called?
Mar 24, 2004 06:05 PM|LINK
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
Diplo
Member
160 Points
32 Posts
Re: Is Page_Unload() *always* called?
Mar 24, 2004 06:46 PM|LINK
pkr
Star
9197 Points
1860 Posts
Re: Is Page_Unload() *always* called?
Mar 25, 2004 06:25 AM|LINK
Diplo
Member
160 Points
32 Posts
Re: Is Page_Unload() *always* called?
Mar 25, 2004 12:18 PM|LINK
PaulWilson
Contributor
3715 Points
745 Posts
ASPInsiders
Re: Is Page_Unload() *always* called?
Mar 25, 2004 04:57 PM|LINK
For the best .NET code, examples, and tools, visit:
WilsonDotNet.com, WilsonWebPortal.com, ORMapper.net