WebRequest, WebClient, and ServicePoint are obsolete

WebRequest, WebClient, and ServicePoint classes are marked as obsolete and generate a SYSLIB0014 warning at compile time.

Version introduced

6.0

Change description

WebRequest, WebClient, and ServicePoint classes were added to .NET Core in version 2.0 for backward compatibility. However, they introduced several runtime breaking changes, for example, WebRequest.GetRequestStream allocates memory for the whole response, and WebClient.CancelAsync doesn't always cancel immediately.

Starting in .NET 6, the WebRequest, WebClient, and ServicePoint classes are deprecated. The classes are still available, but they're not recommended for new development. To reduce the number of analyzer warnings, only construction methods are decorated with the ObsoleteAttribute attribute.

Use the System.Net.Http.HttpClient class instead.

For FTP, since HttpClient doesn't support it, we recommend using a third-party library.

Affected APIs