How to perform a fast web request in C#

前端 未结 4 459
夕颜
夕颜 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:53

    I was having the 30 second delay on 'first' attempt - JamesR's reference to the other post mentioning setting proxy to null solved it instantly!

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_site.url);
    request.Proxy = null; // <-- this is the good stuff
    
    ...
    
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    

提交回复
热议问题