TimBoss TimBoss - 5 months ago 30
C# Question

How to use WebClient with .NetCore?

Is there any way to use a

in a .NET Core application?
If I build the application I get the following error:

Severity Code Description Project File Line
Error CS0246 The type or namespace name 'WebClient' could not be found (are you missing a using directive or an assembly reference?)

I think
is not a part of .NET Core, but is there any alternative?

Answer Source

As @mike z says in the comments, WebClient isn't in the Core repo and likely won't be ported. The Stack Overflow question "Need help deciding between HttpClient and WebClient" has some fairly good answers as to why you should be using the HttpClient instead.

One of the drawbacks mentioned is that there is no built-in progress reporting in the HttpClient. However, because it is using streams, it is possible to write your own. The answers to "How to implement progress reporting for Portable HttpClient" provides an example for reporting the progress of the response stream.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download