Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

.NET Framework 4.0 applications that use the System.Net.HttpWebRequest and related classes may experience slow responses when using Automatic Proxy Detection


Symptoms

Applications based on the .NET Framework 4.0 using the System.Net.HttpWebRequest and related classes may experience a slow response behavior when using Automatic Proxy Detection.

It may also be observed that an application targeting the .NET Framework 4.0 using Automatic Proxy Detection is slower than the same application that targets the .NET Framework 3.5, .NET Framework 3.0, or .NET Framework 2.0.
 
This problem can occur when a Proxy Auto-Configuration (PAC) file is deployed in the environment and the application is using the Automatic Proxy Detection using the .NET Framework.

↑ Back to the top


Cause

The methods in the System.Net.HttpWebRequest and related classes in .NET Framework 3.5, .NET Framework 3.0, and .NET Framework 2.0 use an internal proxy detection mechanism to detect the proxy script, parse the script, and execute the commands in the script.

The methods in the System.Net.HttpWebRequest and related classes in .NET Framework 4.0 were migrated to use the same proxy detection mechanism used by other Windows components. This mechanism uses functions in the native WinHTTP API to retrieve the proxy file, download the proxy script, parse the script, and execute the necessary commands. The proxy script may require resolving DNS addresses, determining the local computer's IP addresses, and determining the local networks. The WinHTTP APIs determine the local IP addresses by querying the local computer for information on all network adapters. This is an expensive operation which may take a considerable amount of time to complete. In addition, depending on the commands in the proxy scripts, this operation to determine the local IP addresses can be repeated several times, adding further time delays.

The internal mechanism used in .NET Framework 3.5, .NET Framework 3.0, and .NET Framework 2.0 uses an internal proxy detection which may be considerably faster depending on the proxy script. The internal mechanism determines the local IP addresses initially and then registers for network change notifications. As long as the network configuration doesn't change while the proxy file is being executed, the overhead to determine the local IP addresses occurs only once. So the time spent in determining local IP addresses can be much lower depending on the commands in the proxy script.

↑ Back to the top


Resolution

To prevent excessive delays, client applications using the .NET Framework 4.0 should use proxy scripts with commands that request the local IP addresses only once, store the result in a local script variable, and reuse this value when needed by the proxy script.

Examples of commands which should be used conservatively in the Proxy Auto-Configuration (PAC) script are:
  • myIpAddress
  • myIpAddressEx
  • dnsResolve

↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 2583681
Revision : 1
Created on : 1/7/2017
Published on : 7/19/2011
Exists online : False
Views : 76