When is IHttpModule.Dispose method called?

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.
 
K

Karl Seguin

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
 
G

Guest

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.
 
K

Karl Seguin

I guess it isn't if you don't know what the ASP.NET pipeline is...which a
lot of people wouldn't.

Karl
 
G

Guest

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.
 
K

Karl Seguin

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top