More stories
Share

Getting a System.Web.Http.ApiController error?


[Updated Oct. 17th, see below]
We've had some reports of sudden errors on Umbraco sites that were absolutely fine the day before and believe we've pinpointed it to Windows a security update that rolled out to Windows Update starting Tuesday this week.

The symptom is that you'll get an error saying:

The type 'System.Web.Http.ApiController' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'
.


The fix for this should be fairly easy: in your web.config find the compilation\assemblies section and add the System.Web.Http assembly there under System.Net.Http:

<add assembly="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />


This seems to help for most people running into this problem. Another thing that might help, if you get errors compiling your code, try referencing System.Web.Http version 4 and setting the build action to "copy local".

We'll update this blog post as more information becomes available.

Update: In addition to the update above, we of course take over Microsoft's recommendation to update to System.Web.Mvc 4.0.0.1. The easiest way to do this is to copy the new version of the dll into your bin folder. You'll also need to update your assemblyBindings if you have one for System.Web.Mvc (else we recommend you add one). So in your web.config the runtime\assemblyBinding section should have the following binding:

<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
</dependentAssembly>


Of course if you've installed Umbraco through NuGet, you simply update using the following command in your package manager console:

Update-Package Microsoft.AspNet.Mvc -Version 4.0.40804


After doing that and building the project, the assemblyBinding will have updated automatically.

Umbraco 6.0.0 and higher ship with MVC4. If you're running an older version of Umbraco with MVC3 in it, the instructions are similar, you need to update to MVC 3 version: 3.0.50813.1 and do an assembly redirect to the new version 3.0.0.1.

Next Story

Umbraco 7.1.7 and 6.2.3 saving you loads of memory

If you don't know Umbraco, here are some numbers behind the world's friendliest CMS

One of the biggest benefits of using Umbraco is that the community is incredibly pro-active, extremely friendly and helpful.

Chances are that if you get an idea for something you would like to build in Umbraco, someone has already built it. So it is very likely that you can get good and friendly advice from someone from the Umbraco community on Our - just ask.

Number of active installs
409.219
Number of active members in the community
220.022
Known free Umbraco packages available
320

Want to be updated on everything Umbraco?

Be one of the first to know about special offers on our products and services. Get invitations to Umbraco events and festivals sent directly to your inbox.

All you need to do is get on our mailing list and soon you'll become a true Umbraco-know-it-all.

Sign up for our monthly newsletter

Are you sure, that's your real e-mail?