About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
An ASP.NET site on IIS returns HTTP Error 500.21 with the text Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list. Microsoft's pages describe two causes for that exact message. The site targets ASP.NET 4 but ASP.NET 4 is not registered in IIS on the server, or the .NET Framework 4.0 configuration for ASP.NET has been damaged.
The first cause has a short Microsoft fix, and the back-out is an IIS configuration backup whose reach Microsoft's pages do not state. The second has a repair for which Microsoft's page gives no way back.
What the error means
Microsoft's IIS status-code page lists 500.21 as "Module not recognized." and 500.19 as "Configuration data is invalid." The page is dated 2025-01-08. That separates this fault from a configuration read error, which is a different status code with its own diagnosis.
Two Microsoft pages carry the full message. The ASP.NET web deployment troubleshooting page shows it as "HTTP Error 500.21 - Internal Server Error. Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list." and says: "The site you have deployed targets ASP.NET 4, but ASP.NET 4 is not registered in IIS on the server." A Dynamics NAV page shows the message without the full stop after "Error" and says it occurs "because the Microsoft .NET Framework 4.0 configuration for ASP .NET has been damaged", which it links to Visual Studio 2012 being installed before Visual Studio 2010 or SQL Server 2008.
Microsoft's IIS integration page explains where handlers live: in Integrated mode, "ASP.NET handler mappings must be specified in the unified <system.webServer>/<handlers> configuration section to take effect." Administrators select the integration mode per application pool.
The 500.21 status is separate from 500.19, 500.22, 500.23 and 500.24 in the same list. Microsoft describes 500.22 and 500.23 as an ASP.NET httpModules or httpHandlers configuration that does not apply in Managed Pipeline mode, and 500.24 as an impersonation configuration that does not apply there. If your status code is one of those, a different page applies. This one is for the message in the title.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| ASP.NET 4 is not registered in IIS | 500.21 on ASP.NET pages | .NET 4 is installed but IIS shows no .NET 4.0 application pools or handler mappings |
| .NET 4 was installed before IIS | Microsoft's Web Deploy Handler page describes static content served without problems and HTTP Error 404.0 – Not Found for ASP.NET content, a different message from the one in the title | Microsoft's pages describe this order of installation as the trigger |
| The .NET Framework 4.0 configuration for ASP.NET is damaged | The same 500.21 message, found on a Dynamics NAV Web server | The server had a later Visual Studio installed first |
Prove the cause before changing anything
All of this only reads. Start with the error itself: request one static file such as an .html page on the same site, and one ASP.NET page. Microsoft's page on registering ASP.NET 4 says that when ASP.NET is not registered, "IIS will serve static content (like HTML files) without any problems" but returns HTTP Error 404.0 for ASP.NET content, so a working static file with a failing ASP.NET page is consistent with ASP.NET 4 not being registered. The 500.21 page itself states only that cause.
Then look at what IIS knows about. In IIS Manager, open the application pool the site uses and note its .NET Framework version and its pipeline mode, and look at the site's Handler Mappings. Microsoft's Web Deploy page lists the symptom as ".NET 4.0 is installed, but there are no .NET 4.0 application pools or handler mappings in IIS". From a command prompt, AppCmd lists the pools:
%systemroot%\system32\inetsrv\APPCMD list apppools
Microsoft's AppCmd page notes that AppCmd is not on the PATH, so use the full path as shown. Note which pools exist and compare them with what the site needs.
Confirm the file the fix runs is on the server before you rely on it. The 500.21 page runs cd %windir%\Microsoft.NET\Framework\v4.0.30319 and then aspnet_regiis.exe -iru. Microsoft's Web Deploy page runs %systemdrive%\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -iru.
Example (illustrative): at contoso.com.au the server app01 hosts an ASP.NET 4 application. index.html loads, default.aspx returns 500.21, and appcmd list apppools shows no pool that runs .NET 4. That is consistent with the first row, so the .NET repair in the last section is not the place to start.
Fix
ASP.NET 4 not registered in IIS
Microsoft's ASP.NET deployment page says: "On the server open an elevated command prompt and register ASP.NET 4" with aspnet_regiis. The Web Deploy page uses the 64-bit folder, and the web deployment handler page says to register the 32-bit version and, for 64-bit web applications, also the 64-bit version.
Before you change it, save the IIS global configuration with a named backup:
%systemroot%\system32\inetsrv\APPCMD add backup BeforeAspNet4Register
Microsoft's AppCmd page says a backup of global server configuration can recover "from unwanted changes to server configuration". It does not say which files aspnet_regiis changes, so this backup covers IIS configuration and nothing else.
Disruptive step: the next commands register ASP.NET 4 with IIS. Microsoft's pages do not say what they change, how long they take or whether sites keep serving while they run, so run them outside business hours.
The 500.21 page's commands, in an elevated command prompt:
cd %windir%\Microsoft.NET\Framework\v4.0.30319
aspnet_regiis.exe -iru
If the server hosts 64-bit web applications, Microsoft's Web Deploy pages also register the 64-bit version:
%systemdrive%\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -iru
Microsoft's deployment page adds that "You might also need to manually set the .NET Framework version of the default application pool", and points to its Deploying to IIS tutorial for the steps.
To undo it, restore the saved backup. Microsoft's AppCmd page says restoring a backup stops the server and restores global configuration to its state at the time the backup was created:
%systemroot%\system32\inetsrv\APPCMD restore backup "BeforeAspNet4Register"
The restore also discards any IIS configuration change made after the backup. Run it only if the registration made things worse and only when a short outage is acceptable. Microsoft's pages do not say whether the restore reverses everything aspnet_regiis changes.
Damaged .NET Framework 4.0 configuration
The Dynamics NAV page says to repair the .NET Framework 4.0.30319 version, either from a command prompt with setup.exe /repair in the SetupCache folder (a different command line for the full framework and the client profile) or with the Microsoft .NET Framework Repair Tool at https://support.microsoft.com/kb/2698555, then to run iisreset. That page applies to Dynamics NAV Web Server components. Microsoft's page does not say how to tell the full framework from the client profile.
Before you change it, take a server-level backup or snapshot, and get the application owner's agreement.
Disruptive step: the repair changes the .NET Framework for every application on the server, and iisreset restarts IIS, so every site on the server stops answering briefly. Run both on the server that returns the error, outside business hours.
Microsoft's page gives no way back from the repair. To undo it, restore the server backup or snapshot you took above.
Confirm the fix
- Request the ASP.NET page that returned 500.21. It should load or fail with an application error, not with 500.21.
- Run
APPCMD list apppoolsagain and check the pool for the site shows the framework version the site targets. - Open the site's Handler Mappings and look for the ASP.NET 4 handlers that were missing before.
What to watch afterwards
- Other sites on the server. Microsoft's pages do not say which sites the registration affects, so test each site that uses ASP.NET.
- The first request after registration. If it fails with a different status code, read that code on its own terms; 500.19 and 500.21 are separate entries in Microsoft's status-code list.
- The saved backup. Microsoft's AppCmd page shows
APPCMD list backupsto list backups, so you can see thatBeforeAspNet4Registeris there before you rely on it.
Read next
Related articles you may want next.
- TroubleshootingIIS HTTP Error 500.19 "The requested page cannot be accessed": read the error code, then the configHTTP Error 500.19 means IIS could not use the site's configuration. The HRESULT code in the error tells you which of Microsoft's documented causes you have: bad XML, a locked section, permissions, a duplicate entry, or a missing module.Read article
- TroubleshootingIIS 502 and 503 Errors: Find the Failing Request LayerUse IIS status fields, worker-process evidence and proxy logs to separate application-pool failures from upstream errors and backend timeouts.Read article
- HostingIIS application pools: recycling, idle time-out and start mode for business web applicationsHow IIS application pool settings can cause slow first requests or loss of worker-local session data, when that can affect sign-in, and how to investigate recycling, the 20-minute idle time-out, on-demand start and Application Initialization.Read article
Risks and limits
These commands have not been run or lab-tested.
Microsoft's pages for this message date from the IIS 7 to 8 and Visual Studio 2012 era and give no range for later Windows Server versions. The ASP.NET deployment page does not say what -iru does, only that it registers ASP.NET 4; the AppCmd and IIS pages do not list what aspnet_regiis changes. Microsoft's pages say nothing about ASP.NET Core sites, which use a different module. A site that returns 500.21 for a reason outside these two causes needs the failed-request detail from IIS, not this fix.
Sources
- HTTP status codes in IIS — Microsoft Learn, page dated 2025-01-08, accessed 22 November 2026
- ASP.NET Web Deployment using Visual Studio: Troubleshooting — Microsoft Learn, page dated 2022-07-21, accessed 22 November 2026
- Troubleshooting: HTTP Error 500 (or 500.21) - Internal Server Error Handler — Microsoft Learn, page dated 2016-06-05, accessed 22 November 2026
- Troubleshoot Web Deploy problems with Visual Studio — Microsoft Learn, page dated 2024-12-02, accessed 22 November 2026
- Configuring a Web Server for Web Deploy Publishing (Web Deploy Handler) — Microsoft Learn, page dated 2023-06-24, accessed 22 November 2026
- ASP.NET Integration with IIS 7 — Microsoft Learn, page dated 2022-03-16, accessed 22 November 2026
- Getting Started with AppCmd.exe — Microsoft Learn, page dated 2022-01-25, accessed 22 November 2026
This article was originally published on .