Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/core/compatibility/6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ If you're migrating an app to .NET 6, the breaking changes listed here might aff
- [Standard numeric format parsing precision](core-libraries/6.0/numeric-format-parsing-handles-higher-precision.md)
- [Unhandled exceptions from a BackgroundService](core-libraries/6.0/hosting-exception-handling.md)

## Networking

- [WebRequest, WebClient, and ServicePoint are obsolete](networking/6.0/webrequest-deprecated.md)

## Windows Forms

- [Selected TableLayoutSettings properties throw InvalidEnumArgumentException](windows-forms/6.0/tablelayoutsettings-apis-throw-invalidenumargumentexception.md)
Expand Down
46 changes: 46 additions & 0 deletions docs/core/compatibility/networking/6.0/webrequest-deprecated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: "Breaking change: WebRequest, WebClient, and ServicePoint are obsolete"
description: Learn about the breaking change in .NET 6.0 where WebRequest, WebClient, and ServicePoint are deprecated in favor of HttpClient.
ms.date: 04/26/2021
---
# WebRequest, WebClient, and ServicePoint are obsolete

<xref:System.Net.WebRequest>, <xref:System.Net.WebClient>, and <xref:System.Net.ServicePoint> classes are marked as obsolete and generate a `SYSLIB0014` warning at compile time.

## Version introduced

6.0

## Change description

<xref:System.Net.WebRequest>, <xref:System.Net.WebClient>, and <xref:System.Net.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 <xref:System.Net.WebRequest>, <xref:System.Net.WebClient>, and <xref:System.Net.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 <xref:System.ObsoleteAttribute> attribute.

## Recommended action

Use the <xref:System.Net.Http.HttpClient?displayProperty=fullName> class instead.

## Affected APIs

- <xref:System.Net.WebRequest>
- <xref:System.Net.HttpWebRequest>
- <xref:System.Net.FtpWebRequest>
- <xref:System.Net.WebClient>
- <xref:System.Net.ServicePoint>

<!--

### Affected APIs

- `T:System.Net.WebRequest`
- `T:System.Net.HttpWebRequest`
- `T:System.Net.FtpWebRequest`
- `T:System.Net.WebClient`
- `T:System.Net.ServicePoint`

### Category

Networking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core libraries feels like a valid category too, but how the docs are organized doesn't allow multiple categories. Are there any criteria to prefer one over the other?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "Core .NET libraries" is for anything that doesn't fit in one of the other categories. So Networking is fine here.


-->
14 changes: 11 additions & 3 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ items:
href: core-libraries/6.0/numeric-format-parsing-handles-higher-precision.md
- name: Unhandled exceptions from a BackgroundService
href: core-libraries/6.0/hosting-exception-handling.md
- name: Networking
items:
- name: WebRequest, WebClient, and ServicePoint are obsolete
href: networking/6.0/webrequest-deprecated.md
- name: Windows Forms
items:
- name: APIs throw ArgumentNullException
Expand Down Expand Up @@ -539,7 +543,7 @@ items:
href: core-libraries/5.0/vector-lerp-behavior-change.md
- name: Vector<T> throws NotSupportedException
href: core-libraries/5.0/vectort-throws-notsupportedexception.md
- name: .NET 1.0-3.1
- name: .NET Core 1.0-3.1
href: corefx.md
- name: Cryptography
items:
Expand Down Expand Up @@ -575,7 +579,7 @@ items:
href: globalization/5.0/unicode-categories-for-latin1-chars.md
- name: ListSeparator values changed
href: globalization/5.0/listseparator-value-change.md
- name: .NET 3.0
- name: .NET Core 3.0
href: globalization.md
- name: Interop
items:
Expand Down Expand Up @@ -603,6 +607,10 @@ items:
href: msbuild.md
- name: Networking
items:
- name: .NET 6
items:
- name: WebRequest, WebClient, and ServicePoint are obsolete
href: networking/6.0/webrequest-deprecated.md
- name: .NET 5
items:
- name: Cookie path handling conforms to RFC 6265
Expand All @@ -615,7 +623,7 @@ items:
href: networking/5.0/negotiatestream-sslstream-dont-fail-on-successive-begin-calls.md
- name: WinHttpHandler removed from .NET runtime
href: networking/5.0/winhttphandler-removed-from-runtime.md
- name: .NET 2.0-3.0
- name: .NET Core 2.0-3.0
href: networking.md
- name: Security
items:
Expand Down