1
我需要執行腳本來訪問綁定到特定IP地址的網站。我在C#中發現了一些使用BindIpEndPointDelegate類的方法。如何使用特定IP地址將請求發送到使用PowerShell的網站
var req = (HttpWebRequest)WebRequest.Create("http://google.com/");
req.ServicePoint.BindIPEndPointDelegate = BindTo;
using (req.GetResponse());
static IPEndPoint BindTo(ServicePoint servicepoint, IPEndPoint remoteendpoint, int retrycount)
{
IPAddress ip = IPAddress.Any; //This is where you specify the network adapter's address
int port = 0; //This in most cases should stay 0. This when 0 will bind to any port available.
return new IPEndPoint(ip, port);
}
我不知道如何將該類傳遞給powershell。
感謝您的幫助!
,你說什麼樣的訪問呢?香草GET請求? POST?或者完全不同的東西? – Jesper
其實,我只需要做一個HttpWebRequest來檢查網站狀態。我的問題是,網站背後的負載平衡具有不同的IP地址的網站實例。我想向所有人發送請求。這就是爲什麼我需要BindIPEndPointDelegate來指定每個IP地址和端口。 – user1657052