C# – Handler “ExtensionlessUrlHandler-Integrated-4.0” has a bad module “ManagedPipelineHandler” in its module list

asp.netciisweb-applications

To be honest, I've tried to turn a dirty trick on IIS and just when I thought that I was going to get away with it, I realized my workaround doesn't work. Here's what I've tried to do:

1) I have ASP.NET application which has Preloader class that inherits IProcessHostPreloadClient and does all the heavy initialization in Preload method implementation (application is complex and it's a part of an enormous system, so it requires approximately 2 minutes to establish connections to all necessary services and pre-instantiate some Unity registrations).

2) I have a lot of work that needs to be done on application shutdown (unsubscribing, disconnecting, disposing,…), and I guess the best place to do it is in *Application_End* method located in Global.asax.

3) Everything works just fine when I have user activity (first request after the Application Pool that contains aforementioned web application is started will cause *Application_Start* to be called and afterwards *Application_End* is called on Application Pool stop or recycle), but problems occur when there is no user activity and application tries to restart itself after being active for 48 hours (configured requirement). Since there was no requests, application officially didn't get started. Ergo, it can't be gracefully stopped since *Application_End* won't be called.

4) Now comes the messy part… I've tried to make a GET request from code at the end of the Preload method, and it worked. But this solution seemed bad to me, even though it worked. So, I've tried a lot of things, and the last thing I tried was this:

SimpleWorkerRequest swr = new SimpleWorkerRequest(string.Empty, string.Empty, tw);
HttpRuntime.ProcessRequest(swr);

… and that has done it's purpose. *Application_Start* was called, (I've checked response, it was containing login page that was supposed to be displayed in initial request) and on Application Pool shutdown application ended gracefully by doing necessary work in *Application_End*.

BUT

After the application was started (preloaded and initiated) in this manner, this is what happened when I wanted to reach application via Web browser:

HTTP Error 500.21 – Internal Server Error
Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

I am unable to figure this out. Can anybody tell me why this happens and how to fix it?

If I don't figure this out, I will go back to first solution (sending GET request from code) but this problem will bug me since I don't even have an idea what's wrong.

Best Answer

Try to re-register ASP.NET with aspnet_regiis -i. It worked for me.

A likely path for .NET 4 (from elevated command prompt):

c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

http://forums.iis.net/p/1190643/2026401.aspx