6

When I install the NuGet package for WebApi, it gives me version 1.0.0.0 of System.Net.Http, yet it references version 2.

I cannot seem to find version 2 for the life of me. When I download .net 4.5 I get System.Net.Http version 4.0.315.x, but I cannot use that because the Web Api assemblies refer to version 2.0.0.0.

Anyone know where I can find this version 2.0.0.0? I've tried the NuGet package manager, mvc4, .net 4.5, and nothing is giving me version 2.

Thanks in advance.

5
  • When I add the WebApi via NuGet, it adds Microsoft.Net.Http v2.0.20505.0, which also brings in System.Net.Http v2.0.0.0. Look in the lib folder in the packages directory. Commented Aug 13, 2012 at 20:14
  • When I go to that folder, and check the version of that System.Net.Http.dll, it's v1.0.0.0. I just removed the package and redownloaded it to be sure. Commented Aug 13, 2012 at 20:20
  • I have the reference to version 2.0.0.0, problem is I don't have the assembly. All my assemblies are either version 1.0.0.0 or 4.0.315.x. Commented Aug 13, 2012 at 20:34
  • 1
    (for future reference) If you have access to the server just install the 4.5 framework and you are done, this is how I resolve this issue... microsoft.com/en-us/download/details.aspx?id=30653 Commented Dec 15, 2012 at 0:41
  • just for the logs: Fileversion != Assemblyversion Commented Mar 11, 2013 at 14:45

1 Answer 1

13

Add the below configuration inside your Web.config file under <system.web> node (assuming your app runs on .NET 4.5, targetFramework attribute is set to 4.5):

<compilation targetFramework="4.5">
  <assemblies>
    <add assembly="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </assemblies>
</compilation>

Also add the below one at the root level under <configuration> node:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
      <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

This should solve your problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.