我需要为 HttpWebRequest 绑定本地 ip 地址(机器有多个 ip)。我创建了委托方法,它被调用并且ip绑定到没有代理的请求,但是一旦我将代理详细信息添加到请求中,回调就不会发生
如何绑定使用代理的 HttpWebRequests 的传出 IP 地址?
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);
}
有没有其他方法可以为 https 绑定这个?