.NET Core 2.1 comes with a great improvement on System.Net.HttpClient
For HttpClient, we built a new from-the-ground-up managed HttpClientHandler called SocketHttpHandler. As you can likely guess, it’s a C# implementation of HttpClient based on .NET sockets and Span.
My application is an ASP.NET Core application hosted as windows service, according to Microsoft this doc , the project is a .NET Core based but its TargetFramework
is .NET framework.
The application works well with .NET Core 2.0 targeting .NET framework 4.7.1.
Recently Microsoft released Microsoft.AspNetCore 2.1.0-rc1-final which is ready for production use. So I tried to upgrade to this version.
so I upgraded TargetFramework
to 4.7.2 and upgrade the reference as bellow.
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.1.0-rc1-final" />
Then it stops working and compiler raises error like The type or namespace name 'HttpClient' could not be found
I am aware of HttpClient
exists in NuGet System.Net.Http
assembly.
However its latest version is 4.3.3 from 8 months ago, which seems to me it does not contain the implementation of SocketHttpHandler.
So my question is: How could I use the latest HttpClient from .NET Core 2.1 targeting .NET framework 4.7.2 ?