I'm using the WebRequest class to make calls to a web service.
I want to set the KeepAlive property to 'false' but i'm not finding this attribute.
How can I do it?
I'm using the WebRequest class to make calls to a web service.
I want to set the KeepAlive property to 'false' but i'm not finding this attribute.
How can I do it?
As Microsoft has mentioned. Source
We advise not to use WebRequest or its derivative classes for the new development. Instead, use the System.Net.Http.Http.HttpClientclass.
WebRequest is the basic abstract class for. NET request/response model to access data from the Internet. So you can use HttpClient instead that has KeepAlive
property.
C# How to set HttpClient Keep-Alive to false
https://learn.microsoft.com/fr-fr/dotnet/api/system.net.http.httpclient?view=netcore-3.1