HttpWebRequest in NET Framework 4.0 uses proxy access by default, so the first Request becomes too slow. Every time you go to Request. GetResponse (), you have to wait for dozens of seconds! However, once this request is successful, it will soon be followed (if it is the same website ). This is not normal! In the past, NET2.0/3.5 was used. This problem occurs when the same code is compiled and executed in the NET4.0 environment. Is it a BUG?
After searching, I finally found the problem. The default proxy in. NET4.0 was enabled.
"It's not set at all in app. cong or machine. config. Hmm. If I'm reading
MSDN docs right, the default for defaultProxy. enabled is TRUE if the element
Isn' t specified at all. That wocould be consistent with my observations.
"
Solution:
Add configuration section in the. config file
<System.net>
<Defaproxy proxy enabled = "false" usedefacrecredentials = "false">
<Proxy usesystemdefaults = "true" proxyaddress = "http: // 192.168.1.10: 3128/" bypassonlocal = "true"/>
<Bypasslist>
<Add address = "[a-z] + \. contoso \. com"/>
</Bypasslist>
<Module/>
</DefaultProxy>
</System.net>
References:
Http://msdn2.microsoft.com/en-us/library/kd3cf2ex (VS.80). aspx