When is IHttpModule.Dispose method called?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I am trying to understand when IHttpModule.Dispose method is called.
Is it called when the Application is disposed, or when the request ends?

If I want to make an object Application-wide and close it when the
application ends can I use that method or write something like this in the
class that implements the IHttpModule?

public void Init(HttpApplication application)
{
application.Disposed +=new EventHandler(application_Disposed);
}

private void application_Disposed(object sender, EventArgs e)
{
// close my object here
}

Thanks in advance.
 
I hope this doesn't sound rude, but the documentation, for 2.0 atleast,
makes this pretty clear:
"The Dispose method performs any final cleanup work prior to removal of the
module from the execution pipeline."

which would mean it's application-wide.

Karl
 
It's what the documentation says for 1.1 too, but it didn't sound to me very
clear. I'd be glad if you could explain the reason why it is so clear.
 
I guess it isn't if you don't know what the ASP.NET pipeline is...which a
lot of people wouldn't.

Karl
 
I am sorry if I made stupid questions, but I think this is not the way to
reply to a question. But thank you anyway.
 
No, I'm the one who's sorry. The question wasn't stupid and I was rude. We
typically aren't like this in here..

Karl
 
It's ok. Anyway trying by myself I found out that using the IHttpModule
Dispose method and an event handler for the Application.Disposed event should
be barely the same. The first occurs right after the second one.
 
Back
Top