A
Andrew Kibler
I have a setup where multiple IPs can be configured for a network card
to allow multiple server programs binding on a port (80) each with their
own IPs.
I want to invoke a HttpWebRequest from a specific IP that corresponds
with a given server. How do I tell HttpWebRequest which IP to request
from?
here is a code snip of setting up a request:
HttpWebRequest httpWebRequest =
HttpWebRequest)WebRequest.Create(requestUri);
httpWebRequest.KeepAlive = false;
WebProxy webProxy = WebProxy.GetDefaultProxy();
webProxy.BypassProxyOnLocal = true;
httpWebRequest.Proxy = webProxy;
HttpWebResponse httpWebResponse;
try
{
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
}
catch (WebException webException)
{
httpWebResponse = (HttpWebResponse)webException.Response;
}
WebHeaderCollection responseHeaders = httpWebResponse.Headers;
byte[] responseHtml = new byte[0];
if(httpWebResponse.ContentLength > 0)
{
Stream httpWebResponseReader =
httpWebResponse.GetResponseStream();
etc
etc
thanks.
to allow multiple server programs binding on a port (80) each with their
own IPs.
I want to invoke a HttpWebRequest from a specific IP that corresponds
with a given server. How do I tell HttpWebRequest which IP to request
from?
here is a code snip of setting up a request:
HttpWebRequest httpWebRequest =
HttpWebRequest)WebRequest.Create(requestUri);
httpWebRequest.KeepAlive = false;
WebProxy webProxy = WebProxy.GetDefaultProxy();
webProxy.BypassProxyOnLocal = true;
httpWebRequest.Proxy = webProxy;
HttpWebResponse httpWebResponse;
try
{
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
}
catch (WebException webException)
{
httpWebResponse = (HttpWebResponse)webException.Response;
}
WebHeaderCollection responseHeaders = httpWebResponse.Headers;
byte[] responseHtml = new byte[0];
if(httpWebResponse.ContentLength > 0)
{
Stream httpWebResponseReader =
httpWebResponse.GetResponseStream();
etc
etc
thanks.