I need to bind the local ip address for an HttpWebRequest (machine has multiple ips). I create the delegate method, and this is called and the ip is bound for requests without a proxy, but once i add proxy details to the request, the callback never occurs
How can i bind the outgoing ip address for HttpWebRequests that use a proxy?
static void MakeRequest(string url, WebProxy myProxy)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.ServicePoint.BindIPEndPointDelegate = new BindIPEndPoint(BindIPEndPointCallback);
request.Proxy = myProxy;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}
public static IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount)
{
// not called when proxy is set
Console.WriteLine("BindIPEndpoint called");
return new IPEndPoint(IPAddress.Parse("192.168.1.58"), 5000);
}
Is there some other way to bind this for https?