Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApplicationShutdownMethodAttribute isn't working on .NET 4.0 #11

Open
adamjasinski opened this issue Mar 6, 2013 · 3 comments
Open

Comments

@adamjasinski
Copy link

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

@davidebbo
Copy link
Owner

Ah, I didn't know that. Do you know if there is a way to fix it so it works in both 4.0 and 4.5? I don't think there is any HttpApplication event that can help here.

@adamjasinski
Copy link
Author

No, there doesn't seem to be any event that would be guaranteed to happen after ALL HttpApplications and HttpModules are disposed.
Application_End event is fired BEFORE HttpApplications/HttpModules from this 'special' pool are disposed (which doesn't make it good enough for uses like DI container disposal).

@davidebbo
Copy link
Owner

Well, if someone comes up with a solution to this, feel free to send a pull request! Until then, I guess it's a 4.5 only feature...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants