IIS 7, HttpHandler and HTTP Error 500.21
Asked Answered
S

7

17

On IIS 7, I'm trying to use custom HttpHandler for my ASP.NET web application. I use pipeline mode "classic", .NET version is 4.0.30319, my web.config configuration for the handler is:

<system.webServer>
<handlers>
    <add name="MyHandler" path="*.myExtension" verb="*" type="Company.App.UI.Controls.MyHandler, Company.App.UI" resourceType="Unspecified" />
</handlers>
</system.webServer> 

When I invoke this handler, I get this error:

HTTP Error 500.21 - Internal Server Error
Handler "MyHandler" has a bad module "ManagedPipelineHandler" in its module list

I did a google search, the most of people fix this issue by re-registering ASP.NET by aspnet_regiis.exe /i command, but this is not working for me (the command finishes, I restart the IIS, but same error). I tried it on two different servers, but got the same result.

What else should I try? Thank you

Sapsucker answered 22/8, 2012 at 8:47 Comment(0)
D
20

It's not possible to configure an IIS managed handler to run in classic mode. You should be running IIS in integrated mode if you want to do that.

You can learn more about modules, handlers and IIS modes in the following blog post:

IIS 7.0, ASP.NET, pipelines, modules, handlers, and preconditions

For handlers, if you set preCondition="integratedMode" in the mapping, the handler will only run in integrated mode. On the other hand, if you set preCondition="classicMode" the handler will only run in classic mode. And if you omit both of these, the handler can run in both modes, although this is not possible for a managed handler.

Downpour answered 22/8, 2012 at 9:53 Comment(4)
I got the same problem. My server is using Window server 2008 R2, IIS 7.0. I come to this folder c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ and run this command aspnet_regiis -i then the problem was solved.Amari
Me too did the aspnet_regiis and it worked :) Thanks @AmariDeloris
I come to this folder c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ and run this command aspnet_regiis -i then the problem was solvedMarola
thank you so much!! it worked as soon as I set siteManager.AppPool.ManagedPipelineMode = ManagedPipelineMode.Integrated;Cartagena
Q
13

Luckily, it’s very easy to resolve. Run the follow command from an elevated command prompt:

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

If you’re on a 32-bit machine, you may have to use the following:

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
Quintan answered 14/7, 2016 at 14:26 Comment(3)
This ONLY worked for me if I removed the .exe I don't know why.Thresher
It worked for me as well on a Win 7 Pro box. Had to run the command prompt as administrator.Chuppah
What does this do?Hedva
J
10

I had the same problem and was solved by running the following in run

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

Jacquline answered 1/12, 2016 at 15:22 Comment(1)
Worked for me too, but I have no idea why. @Paul Gathuo Wagana, can you explain what this magical command actually does?Hedva
A
4

I had the same problem and just solved it. I had posted my own question on stackoverflow:

Can't PUT to my IHttpHandler, GET works fine

The solution was to set runManagedModulesForWebDavRequests to true in the modules element. My guess is that once you install WebDAV then all PUT requests are associated with it. If you need the PUT to go to your handler, you need to remove the WebDAV module and set this attribute to true.

<modules runManagedModulesForWebDavRequests="true">
...
</modules>

So if you're running into the problem when you use the PUT verb and you have installed WebDAV then hopefully this solution will fix your problem.

Aromaticity answered 22/10, 2015 at 21:6 Comment(0)
O
0

On windows server 2016 i have used:

dism /online /enable-feature /featurename:IIS-ASPNET45 /all

Also can be done via Powershell:

Install-WindowsFeature .NET-Framework-45-Features

Octonary answered 10/10, 2017 at 10:58 Comment(0)
I
0

This situation happens because you haven't installed/start service of ASP.net.

Use below command in windows 7,8,10.

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
Immense answered 16/4, 2018 at 11:14 Comment(0)
H
-1

One solution that I've found is that you should have to change the .Net Framework back to v2.0 by Right Clicking on the site that you have manager under the Application Pools from the Advance Settings.

Hurry answered 17/6, 2014 at 12:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.