System.Net.WebException remote name could not be resolved 'http'

I am using System.Net.HttpWebRequest to make a request to a server by setting the proxy property of the object as:

webRequest.Proxy = New WebProxy("10.x.x.x", port);

it works fine but when I specify the https protocol:

webRequest.Proxy = New WebProxy("https://10.x.x.x", port);

it throws the error: "System.Net.WebException remote name could not be resolved 'http'". Please note that even if I use 'https' protocol, in the exception it says "remote name could not be resolved 'http'"

is it something related to the networks settings on the requested server or something that I can handle while making the request?

Jon Skeet
people
quotationmark

You're calling the WebProxy(string, int) constructor - where the string is meant to be a host name, not a URI.

You should call the WebProxy(string) constructor, at which point the string is a URI. If you need to specify a non-default port, put that in the URI, e.g.

webRequest.Proxy = new WebProxy("https://10.1.1.1:12345");

people

See more on this question at Stackoverflow