C# How to set HttpClient Keep-Alive to false

前端 未结 5 1673
一生所求
一生所求 2020-12-14 01:40

I had a low performance problem with HTTP requests on .NET. The HTTP GET request to a REST API on the localhost took about 500 ms to complete. I spent a lot of time to fix i

5条回答
  •  天涯浪人
    2020-12-14 02:31

    See code below:

    HttpClient cli;
    ...
    cli.DefaultRequestHeaders.Add("Connection", "keep-alive");
    cli.DefaultRequestHeaders.Add("Keep-Alive", "600");
    

提交回复
热议问题