System.Net.Http vs Microsoft.Net.Http

I am using ASP.NET 5 and MVC 6. I want to use HttpClient, but I noticed that two NuGet packages are being offered. Which one am I using?

+51
asp.net-core nuget asp.net-core-mvc
Jun 25 '15 at 14:27
source share
2 answers

Depends on the version. Older System.Net.Http ( 2.0 ) packages are obsolete packages that have been deprecated in favor of Microsoft.Http.Net as described:

The Legacy package, System.Net.Http is now included in the Microsoft.Net.Http Package.

They exist to provide HttpClient in previous versions of .NET and the Portable Class libraries. You must use Microsoft.Net.Http in this case.

Since you are using .NET Core, you should use the latest System.Net.Http package (e.g. 4.1.0).

If your project.json targets both full .NET and .NET Core, you need to add the System.Net.Http assembly to the frameworkAssemblies element. For example:

 "frameworks": { "net451": { "frameworkAssemblies": { "System.Net.Http": "4.0.0.0" // HttpClient for full .NET } }, "netstandard1.3": { "dependencies": { "System.Net.Http": "4.1.0", // HttpClient for .NET Core } } } 
+38
Jun 25 '15 at 15:04
source

Microsoft.Net.Http requires additional Microsoft.Bcl dependencies.

For this, if you are only targeting the .NET Framework or .NET Core, System.Net.Http is good. Otherwise, Microsoft.Net.Http would be the best choice, as it could be the next generation.

+5
May 05 '16 at 12:48
source



All Articles