4

Will Asp.net run its full page life cycle although the remote connection was closed unexpectedly to a state that stream data cannot be send the client? It is a blank asp.net page with default values. and I am concern about OnUnLoad event not being executed. Will it actually happen?

Anyone got any detail info on this?

animuson
  • 53,861
  • 28
  • 137
  • 147
Bamboo
  • 2,046
  • 2
  • 16
  • 21

2 Answers2

2

I think you should design your pages in a way that does not rely on that event execution.

The web/network is unpredictable, anything can always happen, browser crash, bug, connection is lost or slow or works and doesn't then works again...

I am convinced that when you close the browser the web request is disposed but since you ask about the web form page life cycle, it concludes with the Page_PreRender then the data is sent to the client, there are so many variables and possibilities that I think is safer to always imagine the whole life cycle will get executed even if there will be nobody to use/consume the response.

Davide Piras
  • 43,984
  • 10
  • 98
  • 147
1

This is just a guess, but I think that client disconnection somehow raises a ThreadAbortException. Hence, any of the next events will not occur any more. You can, of course, try to catch the exception and then free up your resources.

naivists
  • 32,681
  • 5
  • 61
  • 85