Click here to Skip to main content
14,421,009 members
Rate this:
Please Sign up or sign in to vote.
See more:
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.
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Comments
HalliHaida 29-Mar-13 3:38am
   
Hi Jose,

Thanks for the link. But that is not what I am looking for.

I would like to know why setting those two options in IE is working and just setting the Automatic script thing doesn't work. With just the automatic script thing set, I am able to access the internet using IE. So, the HttpWebRequest response should also work right?

But it is not. I am tryin to understand the reason for this behavior.

Please let me know if not clear.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100