Hi All,
I am working on a application which needs to detect internet and download some files from server. I am using http webrequest/response logic for internet detect logic. It is working fine but fails if tried on network which has proxy server in place.
I am on a corporate network and the request has to go through the proxy. To overcome this I used the below logic after searching in google.
HttpWebRequest webRequest =
(HttpWebRequest) (WebRequest.Create("http://www.google.com"));
IWebProxy proxy = WebRequest.GetSystemWebProxy();
proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
webRequest.Proxy = proxy;
HttpWebResponse webResponse =(HttpWebResponse) (webRequest.GetResponse());
With this it started working but has dependency on the following settings in IE->Connections->LAN Settings
1) Automatically detect settings
2) Use automatic configuration script
Both these options needs to be selected for the above logic to work. But I am able to browse internet if I have just the 2nd option (Use automatic configuration script) selected which points to a valid script. So, my expectaion is the logic should also work, if just this option is selected. But it gives the below exception
The remote name could not be resolved: 'www.google.com'
However, if both option 1 and 2 are selected in IE LAN settings, then the above logic works fine.
Please help me understand the reason for this behavior and how to solve.
Thanks in advance.