86

I am getting the error:

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

my web.config file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="CloudConnectHandler" verb="*" path="CloudConnect.aspx" type="CloudConnectHandler" resourceType="Unspecified" />
    </handlers>
  </system.webServer>
  <system.web>
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.0" batch="false">
      <assemblies>
        <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
      </assemblies>
    </compilation>
    <pages>
      <controls>
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
      </controls>
    </pages>
        <identity impersonate="true" />
        <authentication mode="Forms" />
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v4.0" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
    </compilers>
  </system.codedom>
  <appSettings>
    <add key="CloudConnectAuthorization" value="xxxx" />
    <add key="ConnectionInfo" value="xxxx" />
    <add key="ConnectionString" value="xxxx" />
    <add key="DefaultChannel" value="xxxx" />
    <add key="LoginValidationConnectionString" value="xxxx" />
  </appSettings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.640" newVersion="2.0.0.640" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

There is a lot of advice out there indicating that asp.net is not installed correctly. The usual fix is to run:

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

or

%windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -i

I have run both, without any errors. I have restarted IIS, but the problem still persists. The site is using an application pool. The app pool is started, .net framework = 4.0, Managed Pipeline = Classic, Identity = LocalSystem.

I've spent the last couple hours trying to figure out what the problem is. I'm hoping someone can help.

George Mastros
  • 24,112
  • 4
  • 51
  • 59

12 Answers12

187

Please follow these steps:

1) Run the command prompt as administrator.

2) Type either of the two lines below in the command prompt:

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

or

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
ataravati
  • 8,891
  • 9
  • 57
  • 89
Armaan
  • 2,472
  • 2
  • 20
  • 22
  • 2
    Welcome to SO and thanks for your answer. This answer has been flagged for review because of its brevity. While your answer may be technically correct, it could be improved with some more text, explaining what the underlying problem is that the OP is having, and why your answer works. – Software Engineer May 27 '14 at 14:26
  • 8
    here's the more text. cause it works muhahahaha +1. I think the real reason is if you install 4.5.1 first then stick IIS on it doesn't automagically recognize right. or I have that in reverse order. either way. this worked for me – hubson bropa May 28 '14 at 16:51
  • This is the solution! – alexroat Jan 28 '15 at 08:37
  • 4
    I'm building a new 2008 R2 server (yes, in the year 2015) and I installed 4.5.x first and then stuck IIS on afterwards.. like @hubsonBropa mentioned in his comment. This got me past the first of many hurdles. – bkwdesign Mar 04 '15 at 03:56
  • If you are using .NET 4.5.x or 4.6.x, don't be fooled by the answer mentioning 4.0 and thinking it doesn't apply to you. This problem can be related to the order of installation of .NET before IIS, as it was for me. Running the command (in my case the 64 bit version) fixed it even though my application is using .NET 4.5.2. – Coxy May 17 '16 at 02:49
  • Why do I do the same thing over and over?!?!: bang head on wall for a few hours *then* check stackoverflow, then get back to work....moron. – Jester Feb 23 '17 at 20:37
  • I could not execute this command in Windows 10 "This option is not supported on this version of the operating system". I had to go to feature installation in control panel "Turn Windows features on or off". – FrankyHollywood Nov 14 '17 at 21:07
51

I ran into this error on a fresh build of Windows Server 2012 R2. IIS and .NET 4.5 had been installed, but the ASP.NET Server Role (version 4.5 in my case) had not been added. Make sure that the version of ASP.NET you need has been added/installed like ASP.NET 4.5 is in this screenshot.

ASP.NET Server Role

Jeremy Cook
  • 20,840
  • 9
  • 71
  • 77
33

To fix the problem, I tried to run

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

However It didn't work for me. I have to run another command line in CMD window as administrator. Here is the command:

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

or

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

Hope it will help.

Tim Murphy
  • 4,892
  • 4
  • 40
  • 48
Lynn
  • 331
  • 3
  • 2
19

Try switching to Integrated mode. See the following thread:

IIS 7, HttpHandler and HTTP Error 500.21

Community
  • 1
  • 1
Radomir Zaric
  • 230
  • 2
  • 2
  • I had switched it to integrated, which caused a different error. Once I fixed that, everything started working properly. Thank you. – George Mastros Jan 06 '14 at 14:00
  • "Down vote" for this. I already had integrated mode enabled. @Armaan answers it brief but perfectly. – echology Apr 02 '16 at 07:53
  • This answer is valid, it resolve my problem, I used NET 3.5 and got the 500.21 Error. switch to integrated mode resolved my problem. – freedeveloper Feb 23 '18 at 14:33
4

I got this error on my ASP.Net 4.5 app on Windows Server 2012 R2.

Go to start menu -> "Turn windows features on or off". A wizard popped up for me.

Click Next to Server Roles

I had to check these to get this to work, located under Web Server IIS->Web Server-> Application Development (these are based on Jeremy Cook's answer above):

enter image description here

Then click next to Features and make sure the following is checked:

enter image description here

Then click next and Install. At this point, the error went away for me. Good luck!

Rudy Scoggins
  • 431
  • 3
  • 8
3

This is because IIS 7 uses http handlers from both <system.web><httpHandlers> and <system.webServer><handlers>. if you need CloudConnectHandler in your application, you should add <httpHandlers> section with this handler to the <system.web>:

<httpHandlers>
    <add verb="*" path="CloudConnect.aspx" type="CloudConnectHandler" />
</httpHandlers>

and also add preCondition attribute to the handler in <system.webServer>:

<handlers>
  <add name="CloudConnectHandler" verb="*" path="CloudConnect.aspx" type="CloudConnectHandler" preCondition="integratedMode" />
</handlers>

Hope it helps

Evgeny Gorb
  • 1,442
  • 2
  • 13
  • 24
3

I had this issue in Windows 10 when I needed IIS instead of IIS Express. New Web Project failed with OP's error. Fix was

Control Panel > Turn Windows Features on or off > Internet Information Services > World Wide Web Services > Application Development Features

tick ASP.NET 4.7 (in my case)

Neil Thompson
  • 6,356
  • 2
  • 30
  • 53
2

For me, I was getting this error message when using PUT or DELETE to WebAPI. I also tried re-registering .NET Framework as suggested but to no avail.

I was able to fix this by disabling WebDAV for my individual application pool, this stopped the 'bad module' error when using PUT or DELETE.

Disable WebDAV for Individual App Pool:

  1. Click the affected application pool
  2. Find WebDAV Authoring Tools in the list
  3. Click to open it
  4. Click Disable WebDAV in the top right.

This link is where I found the instructions but it's not very clear.

Luke
  • 22,826
  • 31
  • 110
  • 193
  • 1
    My problem exactly. Put and Delete didn't work with WebDav enabled. Thanks for sharing your finding! – ilter Sep 27 '15 at 21:54
0

I had this problem every time I deployed a new website or updated an existing one using MSDeploy.

I was able to fix this by unloading the app domain using MSDeploy with the following syntax:

msdeploy.exe -verb:sync -source:recycleApp -dest:recycleApp="Default Web Site/myAppName",recycleMode=UnloadAppDomain

You can also stop, start, or recycle the application pool - more details here: http://technet.microsoft.com/en-us/library/ee522997%28v=ws.10%29.aspx

While Armaan's solution helped get me unstuck, it did not make the problem go away permanently.

neoscribe
  • 2,203
  • 1
  • 21
  • 18
0

if it is IIS 8 go to control panel, turn windows features on/off and enable Bad "Named pipe activation" then restart IIS. Hope the same works with IIS 7

-1

I discovered that the order of adding roles and features is important. On a fresh system I activate the role "application server" and there check explicitly .net, web server support and finally process activation service Then automatically a dialogue comes up that the role "Web server" needs to be added also.

Jasper
  • 7,031
  • 3
  • 35
  • 43
-1

Install .NET framework as below, it will work .NET version 4.5 as well.

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir

Some time only give aspnet_regiis.exe -i don't work so give aspnet_regiis.exe -ir in above path.

Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57