Solution for HTTP Error 500.21 – Internal Server Error – Bad module “ManagedPipelineHandler” on IIS 7.5

This problem has been encountered after the production server has been upgraded to Windows Sever 2008 R2 and the ASP.NET solution has been moved on the .NET 4.0 platform.

The ASP.NET application was put to run in a ASP.NET v4.0 with Integrated Managed Pipeline application pool. The application was updated using Visual Studio 2010.After installing the necessary IIS 7.5 roles and features and publishing the website, i have encountered this error

HTTP Error 500.21 – Internal Server Error
Handler “WebServiceHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list.

In the Visual Studio Development Server the site was running fine, until we tested the Crystal Reports………, but this is another problem.

If I change the application pool to Classic .NET AppPool the problem does not persist, but it is not the solution.

On the error page, most likely causes are:

  • manged handler is used; however, ASP.NET is not istalled or is not installed completely;
  • there is a typographical error in the configuration for the handler module list.

The first suggestion is the most likely to be true and after searcing the Web I found the source of the problem: installing  SQL Server 2008, after installing Visual Studio 2010 may corrupt IIS Machine level configuration files: Installing VS2010 before VS2008 Results In Corrupt IIS Machine Level Configuration Files

Solutions for this problem are:

  • silent repair of the 4.0 .NET Framework
    • for 32 bit servers with .Net Framework version 4.0.30319 run the command (in command prompt):%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart
    • for 64 bit servers with .Net Framework version 4.0.30319 run the command:%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart
  • install the ASP.NET version and configure IIS to use it
    • open command prompt (Start -> cmd) and for 32 bit servers run the command%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe /i
    • open command prompt (Start -> cmd) and for 64 bit servers run the command%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe /i