Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 7, HttpHandler and HTTP Error 500.21

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

like image 998
Mikee Avatar asked Aug 22 '12 08:08

Mikee


3 Answers

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.

like image 185
João Angelo Avatar answered Nov 09 '22 15:11

João Angelo


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
like image 29
meganhost.com Avatar answered Nov 09 '22 13:11

meganhost.com


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

like image 10
paul Gathuo Wagana Avatar answered Nov 09 '22 13:11

paul Gathuo Wagana