Question about IHttpModule.Dispose and Application_End

I just read this post "When is the IHttpModule.Dispose Method Invoked?" I found this

"The Dispose method does any final cleanup work before the module is removed from the execution pipeline."

which will mean its widespread use.

This is normal. In any case, trying on my own, I found out that using the IHttpModule Dispose Method and the event handler for Application.Disposed the event should be almost the same. The first occurs immediately after the second.

I do not think this is 100% correct ie IHttpModule.Dispose does not always follow Application_End. Let's say I have several instances of the Application object running for my application, which means that each instance of the Application object will have separate instances of modules inside it. Now suppose the time comes when the application pool will be full of application instances, what will happen next? Is it not going to happen if you start deleting instances of the application one by one, and the modules inside the application instance will be placed in the chain. Now this removal of the module does not mean that Application_End will light up after that. The app is still working. I'm right?

+8
c # iis iis-7
source share
2 answers

Yes.

HttpModules - for HttpApplication. Contrary to what its name suggests, the Application_End method in global.asax does NOT start at the end of each HttpApplicaton lifetime. It starts at the end of the life of ALL HttpApplications in the current AppDomain (when the AppDomain breaks down). The same is true for the Application_Start method.

+8
source

Only one instance of the application object per application. There are many session objects, each of which deals with requests or expects to be processed.

The application pool will not be populated with application objects as soon as 1 per application. When the application pool hosts more than 1 application, then there will be a lot of processing, the pool will kill them. Application pools also have health monitoring, which will restart the process after a certain number of requests / memory usage. in this case, existing sessions are left to die, and a new application is launched to process new requests. when all sessions in the old application are dead, the application is disconnected.

See MSDN for more details.

0
source

All Articles