Could not load file or assembly 'System.Net.Http, Version=2.0.0.0 in MVC4 Web API
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
<dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/></dependentAssembly>
which I've changed to
<dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="2.0.0.0"/></dependentAssembly>
Now works like charm.
I had the same problem with deployment my app to appharbor. The problem it does not support .NET 4.5 yet. What I did.
- Switched my project to .NET 4.0 profile.
- Uninstalled Web API NuGet package.
- Installed Web API (Beta) NuGet package again.
- Verified that .csproj file contains for ALL referenced assemblies, so it will always take it from Bin folder, instead of GAC.
Mine worked with:
Note the redirect of 1-4 to 2.0
<dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="2.0.0.0"/></dependentAssembly>