-
Notifications
You must be signed in to change notification settings - Fork 6k
WebRequest deprecation #20310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
WebRequest deprecation #20310
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
docs/core/compatibility/networking/6.0/webrequest-deprecated.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.