-
Notifications
You must be signed in to change notification settings - Fork 49
Description
On .NET Framework 4.0, methods registered with ApplicationShutdownMethodAttribute are not called when a web application is shutting down.
They work as expected when the host machine has .NET Framework 4.5.
Reason: WebActivator considers an application shutting down when a number of its special 'counter' modules (StartMethodCallingModule) goes down to 0.
This doesn't work properly on .NET 4.0 because of a bug in HttpApplicationFactory, which doesn't dispose a 'special' pool of HttpApplications.
(see
http://connect.microsoft.com/VisualStudio/feedback/details/632507/httpmodules-attached-to-the-special-httpapplication-instance-are-not-disposed)
As a result, some copies of StartMethodCallingModule will remain undisposed, their counter won't go down to 0, and ApplicationShutdownMethodAttribute methods won't be called.
This HttpApplicationFactory bug seems to be fixed in .NET 4.5 ('special' HttpApplication pool is getting disposed).