HttpWebRequest exception: "Unable to connect to the remote server" when using .INS config files

Problem 

Taking a System.Net Trace (see My Favorite System.Net Tracing File) you will see that the HttpWebRequest is trying to use a .INS file.

System.Net Verbose: 0 : [0371] WebRequest::Create(https://myserver/ie/update/windows/IEConfig.INS)

It is successfully retrieved but when the request is made you see something similar to this in the .NET log:

System.Net.Sockets Error: 0 : [0371] Exception in the Socket#4094998::Connect - No connection could be made because the target machine actively refused it 192.168.0.202:443

and

System.Net Error: 0 : [0371] Exception in the HttpWebRequest#33574999:: - Unable to connect to the remote server

Resolution

System.Net by design does not process .INS files.  This results in the HTTP Request being made direct and the Proxy is denying this action.

You need choose one of these methods to resolve the issue:

1. Change your environment to use .PAC files.  For example, set this in IE or use the AutoConfigUrl key.

2. Change your .NET code to hard code the proxy information

3. Add proxy configuration information to your <<application>>.exe.config, web.config or machine.config files.

-Jeff