Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
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.
Solution 1:
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
Solution 2:
If you're running into this error with Windows 8/Windows Server 2012 and .Net 4.5 follow these instructions here: http://www.britishdeveloper.co.uk/2013/01/handler-extensionlessurlhandler.html
Go to "turn Windows features on or off" Then Internet Information Services Then World Wide Web Services Then Application Development Features And then enable ASP.NET 4.5
This worked for me (although the wizard and wording is a little different in Windows Server 2012, but you'll figure it out). With this being said, why this is necessary after installing everything through the Web Platform Installer including all of the dependencies is completely beyond me...
Solution 3:
Despite following most of the advice on this page, I was still getting problems on Windows Server 2012. Installing .NET Extensibility 4.5 solved it for me:
Add Roles and Features > Server Roles > Web Server (IIS) > Web Server > Application Development > .NET Extensibility 4.5
Solution 4:
For Windows 10 / Windows Server 2016 use the following command:
dism /online /enable-feature /featurename:IIS-ASPNET45 /all
The suggested answers with aspnet_regiis
doesn't work on Windows 10 (Creators Update and later) or Windows Server 2016:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Start installing ASP.NET (4.0.30319.0).
This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771.
Finished installing ASP.NET (4.0.30319.0).
Interestingly, the "Turn Windows Features On/Off" dialog didn't allow me to untick .NET nor ASP.NET 4.6, and only the above DISM command worked. Not sure whether the featurename is correct, but it worked for me.