tags:

views:

44

answers:

2

Hi I have some c# code (.Net 4) that makes calls to the Internet to get an XML file, however there is a long delay the first time the code block is hit! by adding the below to the app.conf the problem is resolved. However what I would like to do is check if there is a proxy uesd/set and if not then in code before each call turn off the proxy or the detection that is causing the 20 sec delay!

Can this be done? if so how would I do it?

<system.net> 
  <defaultProxy 
    enabled="false" 
    useDefaultCredentials="false" > 
    <proxy/> 
    <bypasslist/> 
    <module/> 
  </defaultProxy> 
</system.net> 
A: 

You may want to try something like this?

  <system.net>
    <defaultProxy enabled ="false">
      <proxy 
          autoDetect ="True"/>
    </defaultProxy>
  </system.net>
Iain
thanks but I'm trying to disable the proxy in c# code before the call and not do it in the app.config.Any idea how replacate it in code?
Adrian
if you use the system.net.webproxy class
Iain
+1  A: 
WebRequest.DefaultWebProxy = new WebProxy();

Adding the above before the call seems to remove the delay.

Adrian
That's the one.
Kyle Rozendo