Does ASP.NET execute the Page_Unload handler regardless of an unhandled exception during page execution, or do you ha开发者_StackOverflow中文版ve to manually catch exceptions in page code blocks to be sure that Unload will always run?
This is just for posterity, since I was searching for this answer and found this page fairly early on.
Tests on an ASP.Net 2.0 website I'm running and the article here:
http://forums.asp.net/t/515267.aspx/1?Is+Page_Unload+always+called+
Seem to indicate that Page_Unload() is always called. (Whether interrupted by Redirect, Transfer, or Exception)
If an unhandled exception occurs, the only event that is triggered is Application_OnError, no more page events are triggered. If you want the page cycle to contine you have to catch the exception.
精彩评论