1

They are all inherited the Interface IHttpHandler,so the asp.net will call they by the same way. But why the aspx page inherited IDispose? Asp.net is how to achieve it?

Dozer
  • 5,025
  • 11
  • 36
  • 52
  • 2
    Read this first: http://stackoverflow.com/questions/5469491/aspx-vs-ashx-main-difference – Sarwar Erfan Dec 18 '11 at 09:13
  • I am so sorry that this question can not solve my problem.The application call the factory (PageHandlerFactory or SimpleHandlerFactory) to make IHttphandler,and process they by the same way(not use "using").So why the aspx page inherited the IDispose – Dozer Dec 18 '11 at 09:33
  • aspx has (supposed to have) UI controls. StakcOverflow is more about fixing programming problems faced during development. If you have very specific product related query, you better ask the vendor, in this case Microsoft. I mean, if you have a implementation problem regarding aspx having IDispose or ashx not having it, then describe the problem. We shall show you a workaround or solution to that problem. But if you need to know why, better ask the team in Microsoft – Sarwar Erfan Dec 18 '11 at 09:49
  • No matter how thank you anyway~ – Dozer Dec 18 '11 at 10:05
  • And my workaround is about "have a implementation problem regarding aspx having IDispose or ashx not having it". I only what to understand the deep reason. Thank you very much. – Dozer Dec 18 '11 at 10:16

2 Answers2

2

ASP.NET page is inheriting from the base System.Web.UI.Page class which in turn implements the abstract System.Web.UI.TemplateControl class that inherits from System.Web.UI.Control which implements IDisposable.

In the code, there is the remark for the Dispose() of the Control class:

// Summary:
//     Enables a server control to perform final clean up before it is released
//     from memory.

That's the reason why .aspx file essentially implements the IDisposable interface.

Now, ASP.NET handler is directly implementing the System.Web.IHttpHandler interface without inheriting any other classes - being independent interface, it does not implement IDisposable - it's up to the programmer to decide whether to add such thing or not.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
0

So your question is, how does the Dispose() code of the aspx (Page) ever get called?

You're making the assumption that ASP.NET framework only sees an IHttpHandler, whether it contains a Page or another implementation. That's almost certainly not true; something needs to call the page's constructor.

You could use a tool like IL Spy to try to find where the different handling is, and what it looks like.

sq33G
  • 3,320
  • 1
  • 23
  • 38