wal*_*wal 8 c# proxy httpwebrequest
我正在使用Windows 7 Ultimate x64.
我首先有一个浏览,发现这个地方,我得到了"解决方案"的问题,而是想知道为什么 -我不想为null DefaultWebProxy的情况下,有一个合法的代理应该被使用.(顺便说一下,我不是一个http代理)
这是一个简单的单元测试,演示了这个问题.
[Test]
public void TestWebRequest()
{
//if I dont include the following line the request takes ~40 seconds.
WebRequest.DefaultWebProxy = null;
var httpRequest = WebRequest.Create("http://google.com");
var stopWatch = new Stopwatch();
stopWatch.Start();
using (var webResponse = httpRequest.GetResponse())//this is the line taking ages.
{
using (var sr = new StreamReader(webResponse.GetResponseStream()))
Trace.WriteLine(sr.ReadToEnd());
}
stopWatch.Stop();
Trace.WriteLine(string.Format("took {0} sec", stopWatch.Elapsed.TotalSeconds));
}
Run Code Online (Sandbox Code Playgroud)
我们可以不要因为IDisposable原因而陷入困境.
我已经看到了这个,需要一些发现才能解决。
就我而言,发生的情况是有人在“Internet 连接选项”的代理字段中输入了“”(空格)并打开使用代理。
这很奇怪,因为它只会导致代理第一次启动时出现长时间延迟,并且如果您返回互联网设置,它不会显示其中存在或曾经有空格。