How to perform a fast web request in C#

前端 未结 4 461
夕颜
夕颜 2020-12-16 09:59

I have a HTTP based API which I potentially need to call many times. The problem is that I can\'t get the request to take less than about 20 seconds, though the same reques

4条回答
  •  时光取名叫无心
    2020-12-16 10:51

    You don't close your Request. As soon as you hit the number of allowed connections, you have to wait for the earlier ones to time out. Try

    using (var response = g.GetResponse())
    {
        // do stuff with your response
    }
    

提交回复
热议问题