.NET 2.0 HttpWebRequest does not use the https Proxy from Internet Explorer Settings

The .NET framework version 2.0 has the ability to get the IE proxy Settings and use them when making a WebRequest.  However it only will read the http static proxy and not use the https value when specified.  See this example:


I would expect this code to return http://secureproxy:8080 for the proxy when I specify  https://someserver as an argument to this code:

using System;
using System.Net;
public class Test {
public static void Main(string[] args)     {

IWebProxy iwp20 = WebRequest.DefaultWebProxy;
Console.WriteLine(iwp20.GetProxy(new Uri(args[0])).ToString());
HttpWebRequest aReq = HttpWebRequest.Create(args[0])as HttpWebRequest;
Console.WriteLine(aReq.Proxy.GetProxy(new Uri(args[0])));

It does not!  It returns http://proxy:8080.

This is a problem with the 2.0 framework.  Thankfully it HAS been fixed in the 4.0 framework!

An alternative is to code the https proxy information in the code or set in in the application .config file.

Let me know if you found this Blog entry useful!

Comments (2)

  1. RichB says:

    Thankyou! Someone else confirming my suspicion. I tried (and failed) to use SourceServer debugging to try to confirm this.

  2. k. says:

    Thank you for confirming my fears. I have exactly the same issue on .NET 3.5 (sadly, I cannot use 4.0)

Skip to main content