Could not load file or assembly 'System.Net.Http, Version= in MVC4 Web API


I have a bit of a weird problem.
I developed an app with MVC 4 and the new Web API and it works fine locally. I installed MVC4 on the server and deployed the app. Now I get the following error:

Could not load file or assembly 'System.Net.Http, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in

Funny enough, the version of System.Net.Http that I locally have either in my package folder or in the ASP.NET MVC 4\Assemblies folder is I actually removed the reference to System.Net.Http from my project, but I still get the same message. I'm a bit confused about where it gets the reference from and why it would work locally but not on the server.

Looking at the nuget dependencies:

ASP.NET WEb API Core Libraries (Beta) depends on System.Net.Http.Formatting.
And System.Net.Http.Formatting depends on System.Net.Http.
I guess that is where this comes from. But I do have Version 2.0.20126.16343 of this package installed, it's just that the dll inside has version

Am I missing something?


This is a sub-application of another ASP.NET app, but the other one is still based on WebForms. So, something is getting messed up. But if I do a clean under the assembly section in the web.config if does not even find the app itself anymore.

This question is tagged with

~ Asked on 2012-02-24 14:00:11

The Best Answer is


I had the same problem with deployment my app to appharbor. The problem it does not support .NET 4.5 yet. What I did.

  1. Switched my project to .NET 4.0 profile.
  2. Uninstalled Web API NuGet package.
  3. Installed Web API (Beta) NuGet package again.
  4. Verified that .csproj file contains for ALL referenced assemblies, so it will always take it from Bin folder, instead of GAC.

~ Answered on 2012-03-28 07:25:56


I had the same error while deploying previously converted (from .NET 4.5 to 4.0) web app on IIS 6.0.

In the web.config runtime section I've found

    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
    <bindingRedirect oldVersion="" newVersion=""/>

which I've changed to

    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
    <bindingRedirect oldVersion="" newVersion=""/>

Now works like charm.

~ Answered on 2012-04-20 16:17:06

Most Viewed Questions: