Delay when calling Web Service from .Net client

Article translations Article translations
Close Close
Article ID: 968699 - View products that this article applies to.
Expand all | Collapse all
Source: Microsoft Support

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

Symptom



When calling a web service from a .net client you may see a delay.

From Internet Explorer, it may take a couple of seconds for the request to complete but when calling the same web method from a .net client it takes an extra 20 seconds.

Cause



Proxy auto detection delay

Resolution



Use one of the following methods:

 

Method 1:  Turn off “Automatically Detect Settings” in Internet Explorer

 

Method 2:  Modify machine.config or app.config to disable .Net framework from using the autoproxy feature.

<configuration>

<system.net>

<defaultProxy >

<!-- Disable Autoproxy-->

<proxy autoDetect="false"/>

</defaultProxy>

</system.net>

</configuration>

More Information



The following article does an excellent job of explaining how proxy support works in .net framework:

 

"Take the Burden Off Users with Automatic Configuration in .NET"

http://msdn.microsoft.com/en-us/magazine/cc300743.aspx

 

Here is a snippet from the section titled "Proxy Support in the .NET Framework 2.0" which explains the reason for the delay when the Autoproxy protocol is implemented:

"Automatic proxy configuration is now fully supported. The .NET Framework 2.0 reads the complete settings from the registry, including the automatic configuration flags and any explicitly provided script location. Automatic detection happens by first using the DHCPINFORM message and then using the DNS resolution techniques already described. Once the script location is identified, the script is

downloaded, compiled into an in-memory assembly, and then executed in a sandbox app domain where minimal permissions are granted.

 

In fact, no code access security (CAS) permissions are granted to the script other than the execution permission. Minimal permissions mean that rogue scripts can't do anything significant other than call the few functions exposed to the script. For a detailed sample of how to host and run your own scripts in a sandbox app domain, see the sidebar, "Hosting the Proxy Script."

 

Failover is also built in. If auto-detection fails and if you have entered an explicit script location, then that script is downloaded and run. If both fail and if you have a static proxy, then the static proxy is used as a fallback. If all fail, a direct connection to the target URL is attempted."

 

So, all of the above happens when the registry key is examined and the value indicates “Automatically detect settings”. The reason for the delay is the time it takes to do all of the above before trying

the direct connection.

 

If you have to use a specific proxy server, specify it in code or config file through <defaultProxy> setting, which is documented in MSDN:

"<defaultProxy> Element (Network Settings)"

http://msdn.microsoft.com/en-us/library/kd3cf2ex(VS.80).aspx

 

For additional information, see the following:

 

·         307220 HOW TO: Configure an XML Web Service Client by Using the .NET Framework to Work with a Proxy Server    http://support.microsoft.com/default.aspx?scid=kb;EN-US;307220

 

·         330221 PRB: Common Proxy Server and Firewall Issues with MapPoint Web Services http://support.microsoft.com/default.aspx?scid=kb;EN-US;330221

 

·         "Take the Burden Off Users with Automatic Configuration in .NET" http://msdn.microsoft.com/en-us/magazine/cc300743.aspx

 

 

How to change the machine.config to disable the default proxy settings

Here is an example how you can change the machine.config to disable using the default settings for the proxy, and instead specify your own proxy settings:

<defaultProxy>

<proxy

usesystemdefault = "false"

proxyaddress="<http://proxyserver:port>"

bypassonlocal="true"

/>

<bypasslist>

<add address="100.100.100.100" />

</bypasslist>

</defaultProxy>

 

You can, alternatively, set the proxy name and bypass list in code on the Proxy property on the web service object:

"WebProxy Class"

http://msdn.microsoft.com/en-us/library/system.net.webproxy(VS.80).aspx

 

 

 

 

DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

Properties

Article ID: 968699 - Last Review: March 6, 2009 - Revision: 1.0
APPLIES TO
  • Microsoft Web Services Enhancements for Microsoft .NET 2.0
  • Web Services Enhancements 3.0 for Microsoft .Net
  • Microsoft .NET Framework 2.0
  • Microsoft .NET Framework 3.0
  • Microsoft .NET Framework 3.5
Keywords: 
kbnomt kbrapidpub KB968699

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com