Problem
To be honest, I tried a dirty trick on IIS, and just when I thought I was getting away with it, I discovered my workaround didn’t work. Here’s what I’ve attempted to accomplish:
1) I have an ASP.NET application with a Preloader class that inherits IProcessHostPreloadClient and handles all heavy initialization in the Preload method implementation (the application is complex and it’s part of a large system, so it takes about 2 minutes to connect to all necessary services and pre-instantiate some Unity registrations).
2) I have a lot of work to perform on application shutdown (unsubscribing, disconnecting, disposing, etc. ), and I think the best place to accomplish it is in the Global.asax *Application End* method.
3) Everything works fine when there is user activity (the first request after the Application Pool containing the aforementioned web application is started causes *Application Start* to be called, and then *Application End* is called when the Application Pool is stopped or recycled), but there are issues when there is no user activity and the application tries to restart itself after 48 hours of inactivity (configured requirement). Because there were no requests, the application was not officially started. As a result, it cannot be gently terminated because *Application End* will not be called.
4) Now comes the moment where things get a little dirty… At the end of the Preload method, I tried making a GET request from code, and it worked. However, despite the fact that it worked, I found this method to be unsatisfactory. So, I’ve tried a bunch of different things, and the most recent one was this:
SimpleWorkerRequest swr = new SimpleWorkerRequest(string.Empty, string.Empty, tw);
HttpRuntime.ProcessRequest(swr);
…and it’s served its purpose. On Program Pool termination, *Application Start* was called (response contained login page that was expected to be displayed in initial request) and application stopped gracefully by executing necessary work in *Application End*.
BUT
When I tried to access the application via Web browser after it had been launched (preloaded and initiated) in this manner, this is what happened:
I’m stumped. Is there anyone who can explain why this occurs and how to resolve it?
If I can’t figure it out, I’ll revert to the initial approach (sending GET requests from code), but this problem will continue to bother me because I have no understanding what’s wrong.
Asked by Ivan Peric
Solution #1
Use aspnet regiis -i to re-register ASP.NET. It was effective for me.
A possible installation path for.NET 4 (from an elevated command prompt):
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
http://forums.iis.net/p/1190643/2026401.aspx
Answered by danijelk
Solution #2
If you’re having trouble with this problem under Windows 8/Windows Server 2012 and.Net 4.5, take these steps: http://www.britishdeveloper.co.uk/2013/01/handler-extensionlessurlhandler.html
Select “turn Windows features on or off” from the drop-down menu. Then there are the Internet Information Services. Then there’s the World Wide Web Services. Then there are the features of application development. Then turn on ASP.NET 4.5.
This worked for me (although the wizard and language in Windows Server 2012 are a little different, but you’ll figure it out). With that stated, I’m not sure why this is required after installing everything using the Web Platform Installer, including all dependencies…
Answered by Zach
Solution #3
Despite following the most of the recommendations on this page, I was still having issues with Windows Server 2012. I was able to resolve the issue by installing.NET Extensibility 4.5:
Roles and Features > Add Roles and Features Server Roles > Web Server (IIS) > Web Server > Application Development >.NET Extensibility.NET Extensibility.NET Extensibility.NET Extensibility.NET Extensibility.NET Extensibility.NET Extens
Answered by Jonathan
Solution #4
Use the following command for Windows 10 / Windows Server 2016:
/enable-feature /featurename:IIS-ASPNET45 /all dism /online
On Windows 10 (Creators Update and later) and Windows Server 2016, the proposed replies with aspnet regiis do not work:
I couldn’t untick.NET or ASP.NET 4.6 in the “Turn Windows Features On/Off” menu, so I had to use the DISM command instead. Although I’m not sure if the featurename is correct, it worked for me.
Answered by Bart Verkoeijen
Solution #5
One of the following commands should be executed:
For Windows 32-bit operating systems:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
For Windows 64-bit operating systems:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -I
Answered by user3896335
Post is based on https://stackoverflow.com/questions/13162545/handler-extensionlessurlhandler-integrated-4-0-has-a-bad-module-managedpipeli