Adrian
Adrian

Reputation: 33

system.net default proxy c# .Net 4

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> 

Upvotes: 1

Views: 5385

Answers (2)

Adrian
Adrian

Reputation: 33

WebRequest.DefaultWebProxy = new WebProxy();

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

Upvotes: 2

Iain
Iain

Reputation: 6452

You may want to try something like this?

  <system.net>
    <defaultProxy enabled ="false">
      <proxy 
          autoDetect ="True"/>
    </defaultProxy>
  </system.net>

Upvotes: 0

Related Questions