Reputation: 31546
I am using HttpClient to make a POST request to a ASP.NET WEB API. I want to disable the Keep Alive connections.
How do I disable keep alive?
Upvotes: 2
Views: 839
Reputation: 149538
You can explicitly create a HttpWebRequest
and set its KeepAlive
property to false:
string url = "" //Add your url here
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.KeepAlive = false;
var httpClient = new HttpClient();
httpClient.SendAsync(request);
HttpClient
wraps the creation of the HttpWebRequest
for you. But, when you want to more fine-grained control over the request being made, you still have to generate it yourself.
Upvotes: 1