Skip to content

Commit 04c3392

Browse files
author
Jan Jahoda
authored
WebRequest deprecation (#20310)
1 parent f2b29d1 commit 04c3392

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

docs/core/compatibility/6.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ If you're migrating an app to .NET 6, the breaking changes listed here might aff
3535
- [Standard numeric format parsing precision](core-libraries/6.0/numeric-format-parsing-handles-higher-precision.md)
3636
- [Unhandled exceptions from a BackgroundService](core-libraries/6.0/hosting-exception-handling.md)
3737

38+
## Networking
39+
40+
- [WebRequest, WebClient, and ServicePoint are obsolete](networking/6.0/webrequest-deprecated.md)
41+
3842
## Windows Forms
3943

4044
- [Selected TableLayoutSettings properties throw InvalidEnumArgumentException](windows-forms/6.0/tablelayoutsettings-apis-throw-invalidenumargumentexception.md)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: "Breaking change: WebRequest, WebClient, and ServicePoint are obsolete"
3+
description: Learn about the breaking change in .NET 6.0 where WebRequest, WebClient, and ServicePoint are deprecated in favor of HttpClient.
4+
ms.date: 04/26/2021
5+
---
6+
# WebRequest, WebClient, and ServicePoint are obsolete
7+
8+
<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.
9+
10+
## Version introduced
11+
12+
6.0
13+
14+
## Change description
15+
16+
<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.
17+
18+
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.
19+
20+
## Recommended action
21+
22+
Use the <xref:System.Net.Http.HttpClient?displayProperty=fullName> class instead.
23+
24+
## Affected APIs
25+
26+
- <xref:System.Net.WebRequest>
27+
- <xref:System.Net.HttpWebRequest>
28+
- <xref:System.Net.FtpWebRequest>
29+
- <xref:System.Net.WebClient>
30+
- <xref:System.Net.ServicePoint>
31+
32+
<!--
33+
34+
### Affected APIs
35+
36+
- `T:System.Net.WebRequest`
37+
- `T:System.Net.HttpWebRequest`
38+
- `T:System.Net.FtpWebRequest`
39+
- `T:System.Net.WebClient`
40+
- `T:System.Net.ServicePoint`
41+
42+
### Category
43+
44+
Networking
45+
46+
-->

docs/core/compatibility/toc.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ items:
6161
href: core-libraries/6.0/numeric-format-parsing-handles-higher-precision.md
6262
- name: Unhandled exceptions from a BackgroundService
6363
href: core-libraries/6.0/hosting-exception-handling.md
64+
- name: Networking
65+
items:
66+
- name: WebRequest, WebClient, and ServicePoint are obsolete
67+
href: networking/6.0/webrequest-deprecated.md
6468
- name: Windows Forms
6569
items:
6670
- name: APIs throw ArgumentNullException
@@ -539,7 +543,7 @@ items:
539543
href: core-libraries/5.0/vector-lerp-behavior-change.md
540544
- name: Vector<T> throws NotSupportedException
541545
href: core-libraries/5.0/vectort-throws-notsupportedexception.md
542-
- name: .NET 1.0-3.1
546+
- name: .NET Core 1.0-3.1
543547
href: corefx.md
544548
- name: Cryptography
545549
items:
@@ -575,7 +579,7 @@ items:
575579
href: globalization/5.0/unicode-categories-for-latin1-chars.md
576580
- name: ListSeparator values changed
577581
href: globalization/5.0/listseparator-value-change.md
578-
- name: .NET 3.0
582+
- name: .NET Core 3.0
579583
href: globalization.md
580584
- name: Interop
581585
items:
@@ -603,6 +607,10 @@ items:
603607
href: msbuild.md
604608
- name: Networking
605609
items:
610+
- name: .NET 6
611+
items:
612+
- name: WebRequest, WebClient, and ServicePoint are obsolete
613+
href: networking/6.0/webrequest-deprecated.md
606614
- name: .NET 5
607615
items:
608616
- name: Cookie path handling conforms to RFC 6265
@@ -615,7 +623,7 @@ items:
615623
href: networking/5.0/negotiatestream-sslstream-dont-fail-on-successive-begin-calls.md
616624
- name: WinHttpHandler removed from .NET runtime
617625
href: networking/5.0/winhttphandler-removed-from-runtime.md
618-
- name: .NET 2.0-3.0
626+
- name: .NET Core 2.0-3.0
619627
href: networking.md
620628
- name: Security
621629
items:

0 commit comments

Comments
 (0)