Web Api: System.Net.Http version 2.0.0.0 not found

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

I can not 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 this because Web Api assemblies are of version 2.0.0.0.

Does anyone know where I can find this version 2.0.0.0? I tried the NuGet package manager, mvc4, .net 4.5, and nothing gives me version 2.

Thanks in advance.

+6
source share
1 answer

Add the following configuration to the Web.config file in the <system.web> node section (assuming your application is running in .NET 4.5, the targetFramework attribute targetFramework 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 below one at the root level in the <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.

+12
source

Source: https://habr.com/ru/post/922773/


All Articles