1

I have set breakpoints in my Page Dispose (which overrides but then calls the base Dispose) method and my OnDisposed handler.

The OnDisposed handler is never called, but the Page Dispose() method is.

If you can't call the handler, what's the point of having the event?

This question is similar to this question.

Community
  • 1
  • 1
user420667
  • 6,552
  • 15
  • 51
  • 83

1 Answers1

1

AutoEventWireup="true" is what you need for OnDisposed to be called.

What does AutoEventWireUp page property mean?

Here is a nice answer on why the breakpoint might not be hit.

When OnDisposed is triggered

Well they're all part of the page lifecycle, but the trouble with disposal is that it might happen after the page lifecycle has ended. When object reference go out of scope they are left to the garbage collector to dispose of, and this can happen after the page has completely finished, which is why you can't guarantee to breakpoint into them. You could explicitly force the disposal, but it's not really going to help your situation, since these are server events anyway. At least, that's what I assume you want; a way to save the client side state of the page.

Community
  • 1
  • 1
rick schott
  • 21,012
  • 5
  • 52
  • 81
  • mine already is autoeventwiredup. All other Events are triggered. (onunload, oninit, etc.) – user420667 Aug 24 '11 at 22:44
  • thanks for pursuing this. I actually tried "explicitly" disposing them, and that didn't work either. As far as I'm concerned this event is useless and will only lead to confusion. – user420667 Aug 24 '11 at 22:54
  • also, I don't understand the argument that you can't breakpoint into them. Maybe not on the client-side that makes sense... but why not on the server side? Thanks. – user420667 Aug 24 '11 at 22:56
  • One other thing... one of the commenters suggested to write to a database. Instead I attempted to write to a file in the handler. No file was written. – user420667 Aug 24 '11 at 23:05
  • Maybe something has a handle on it? Try a memory profiler, that's the only way to truly know. – rick schott Aug 24 '11 at 23:57
  • Unfortunately I don't have one of those. Have you been able to get the Dispose handler called? – user420667 Aug 25 '11 at 01:05