Httpwebrequest Exception Unable To Connect To The Remote Server When Using Ins Config Files
- 24 Mar 2009
Problem
Taking a <a title=”System.Net Trace” href=”http://msdn.microsoft.com/en-us/library/ty48b824.aspx” target=_blank mce_href=”http://msdn.microsoft.com/en-us/library/ty48b824.aspx”>System.Net Trace</a> (see <a title=”My Favorite System.Net Tracing File” href=”http://blogs.msdn.com/jpsanders/archive/2009/03/24/my-favorite-system-net-trace-configuration-file-dumps-process-id-and-date-time-information.aspx” target=_blank mce_href=”http://blogs.msdn.com/jpsanders/archive/2009/03/24/my-favorite-system-net-trace-configuration-file-dumps-process-id-and-date-time-information.aspx”>My Favorite System.Net Tracing File</a>) you will see that the HttpWebRequest is trying to use a .INS file.
System.Net Verbose: 0 : [0371] WebRequest::Create(http://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:
-
Change your environment to use .PAC files. For example, set this in IE or use the <a title=AutoConfigUrl href=”http://msdn.microsoft.com/en-us/library/cc232672(PROT.13).aspx” target=_blank mce_href=”http://msdn.microsoft.com/en-us/library/cc232672(PROT.13).aspx”>AutoConfigUrl</a> key.
-
Change your .NET code to hard code the <a title=”proxy information” href=”http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.proxy(VS.80).aspx” target=_blank mce_href=”http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.proxy(VS.80).aspx”>proxy information</a>
-
Add <a title=”proxy configuration” href=”http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx” target=_blank mce_href=”http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx”>proxy configuration</a> information to your «application».exe.config, web.config or machine.config files.
-Jeff
<< Go Back