C
Clinton Forbes
I recently encountered a problem with the following piece of code in
an ASP.NET application that has been running successfully for a couple
of months. It requests a web-page from an external web-site, using
our corporate proxy.
Our company has two proxy servers with the same DNS name. If you
execute the nslookup command (at the Windows command prompt), two IP
addresses are returned. When one of the proxy server crashes (as it
did the other day), Internet Explorer continues to work correctly.
However my code failed until the dead proxy server was fixed. It
seemed to cache the IP address of the failed proxy server and continue
to try and use that machine rather than switching to the live machine.
Is there anything I can do to stop this behaviour?
Here is the code:
HttpWebRequest hwrRequest = (HttpWebRequest)WebRequest.Create(
IntranetConfiguration.ExternalSystemConnectionStrings[sExternalSystemKey]);
hwrRequest.Timeout = REQUEST_TIMEOUT;
//Set up proxy information
hwrRequest.Proxy = new WebProxy(
IntranetConfiguration.Proxy.Address,
IntranetConfiguration.Proxy.Port);
hwrRequest.Proxy.Credentials = new NetworkCredential(
IntranetConfiguration.Proxy.Username,
IntranetConfiguration.Proxy.Password);
//Go and get text response from Shareprice service
HttpWebResponse hwrResponse =
(HttpWebResponse)hwrRequest.GetResponse();
Stream strResponse = hwrResponse.GetResponseStream();
StreamReader srResponse = new StreamReader(strResponse);
sHtmlText = srResponse.ReadToEnd();
an ASP.NET application that has been running successfully for a couple
of months. It requests a web-page from an external web-site, using
our corporate proxy.
Our company has two proxy servers with the same DNS name. If you
execute the nslookup command (at the Windows command prompt), two IP
addresses are returned. When one of the proxy server crashes (as it
did the other day), Internet Explorer continues to work correctly.
However my code failed until the dead proxy server was fixed. It
seemed to cache the IP address of the failed proxy server and continue
to try and use that machine rather than switching to the live machine.
Is there anything I can do to stop this behaviour?
Here is the code:
HttpWebRequest hwrRequest = (HttpWebRequest)WebRequest.Create(
IntranetConfiguration.ExternalSystemConnectionStrings[sExternalSystemKey]);
hwrRequest.Timeout = REQUEST_TIMEOUT;
//Set up proxy information
hwrRequest.Proxy = new WebProxy(
IntranetConfiguration.Proxy.Address,
IntranetConfiguration.Proxy.Port);
hwrRequest.Proxy.Credentials = new NetworkCredential(
IntranetConfiguration.Proxy.Username,
IntranetConfiguration.Proxy.Password);
//Go and get text response from Shareprice service
HttpWebResponse hwrResponse =
(HttpWebResponse)hwrRequest.GetResponse();
Stream strResponse = hwrResponse.GetResponseStream();
StreamReader srResponse = new StreamReader(strResponse);
sHtmlText = srResponse.ReadToEnd();