Keywords: IIS Configuration | ASP.NET Error | Module Registration
Abstract: This article provides a comprehensive analysis of the HTTP 500.21 error encountered when configuring ASP.NET MVC 3 projects in IIS, focusing on the root cause of Handler "PageHandlerFactory-Integrated" having a bad module "ManagedPipelineHandler". Through in-depth exploration of ASP.NET 4.0 integration mechanisms with IIS, it offers step-by-step guidance using the aspnet_regiis.exe tool for problem resolution, including specific commands for both 32-bit and 64-bit systems. The article also discusses application pool configuration verification and preventive measures to help developers completely resolve such deployment issues.
Problem Background and Error Analysis
When deploying ASP.NET MVC 3 projects to a local IIS environment, developers frequently encounter HTTP 500.21 Internal Server Error. The specific error message indicates that Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list. This error signifies that IIS cannot properly recognize and process ASP.NET requests, typically occurring when .NET Framework 4.0 integration with IIS is incomplete.
Root Cause Investigation
Through thorough analysis, the primary cause of this error is the incomplete installation of ASP.NET 4.0 framework into IIS. Even when the ASP.NET option is checked in the Windows Features dialog, the system may fail to properly register all necessary handlers and modules. This situation commonly occurs in scenarios such as:
- .NET Framework registration status changes after operating system updates
- Improper IIS installation sequence leading to incomplete integration
- Architecture mismatch (32-bit vs 64-bit)
Solution Implementation
To resolve this issue, the ASP.NET IIS Registration Tool (aspnet_regiis.exe) must be used to re-register the ASP.NET 4.0 framework. The specific implementation steps are as follows:
Step 1: Determine System Architecture
First, confirm the architecture type of the operating system, which will determine which version of the registration tool to use.
Step 2: Execute Registration Command
For 64-bit operating systems, open Command Prompt with administrator privileges and execute the following command:
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
For 32-bit operating systems, the corresponding command is:
%windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -i
Important Note: Command Prompt must be run with administrator privileges, achievable by pressing <kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>ENTER</kbd> combination.
Configuration Verification and Optimization
After completing the registration, verify that the application pool configuration is correct:
- Ensure the application pool uses .NET Framework 4.0
- Check that the managed pipeline mode is set to Integrated
- Verify appropriate application pool identity settings
Preventive Measures and Best Practices
To prevent similar issues from recurring, it is recommended to:
- Ensure .NET Framework 4.0 is properly installed before installing IIS
- Follow correct installation sequence when configuring development environments
- Regularly check the integration status between IIS and .NET Framework
- Perform complete environment validation before deployment
Technical Principles Deep Dive
The primary function of the aspnet_regiis.exe tool is to register ASP.NET file mappings and configuration settings with IIS. When executing the -i parameter, this tool will:
- Create necessary application pools in IIS
- Register ASP.NET ISAPI extensions
- Configure handler mappings and modules
- Set up appropriate file extension associations
This process ensures that IIS can correctly recognize and process ASP.NET requests, which is particularly crucial for the routing mechanisms used by MVC frameworks.