SYSLIB0014: WebRequest, HttpWebRequest, ServicePoint, WebClient are obsolete
The following APIs are marked as obsolete, starting in .NET 6. Using them in code generates warning SYSLIB0014
at compile time.
- WebRequest()
- System.Net.WebRequest.Create
- System.Net.WebRequest.CreateHttp
- System.Net.WebRequest.CreateDefault(Uri)
- HttpWebRequest(SerializationInfo, StreamingContext)
- ServicePointManager (Starting in .NET 9)
- System.Net.ServicePointManager.FindServicePoint
- WebClient()
To reduce the number of analyzer warnings, the ServicePoint class is not marked as obsolete, but all ways of obtaining its instances are.
Settings on ServicePointManager and ServicePoint no longer affect SslStream or HttpClient.
Use HttpClient instead.
For more information, see HttpWebRequest to HttpClient migration guide.
If you must use the obsolete APIs, you can suppress the warning in code or in your project file.
To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.
// Disable the warning.
#pragma warning disable SYSLIB0014
// Code that uses obsolete API.
// ...
// Re-enable the warning.
#pragma warning restore SYSLIB0014
To suppress all the SYSLIB0014
warnings in your project, add a <NoWarn>
property to your project file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);SYSLIB0014</NoWarn>
</PropertyGroup>
</Project>
For more information, see Suppress warnings.
.NET feedback
.NET is an open source project. Select a link to provide feedback: