WebClient.DownloadString takes about 15 seconds when first called

后端 未结 2 865
抹茶落季
抹茶落季 2021-01-18 16:57
string url = \"http://google.com/index.html\";
WebClient client = new WebClient();
Stopwatch sw = new Stopwatch();
sw.Start();
string text = client.DownloadString(ur         


        
2条回答
  •  半阙折子戏
    2021-01-18 17:29

    Your machine is configured to perform Automatic Proxy Detection.

    You can disable it here:

    Screenshot

    Alternatively, you can manually override the proxy to be used by the WebClient; null means no proxy:

    client.Proxy = null;
    

    However, you should offer the user to configure a proxy in your application in this case, because some users have to use a proxy when accessing the Web.

提交回复
热议问题