我们正在使用一个负载平衡服务器,它将我们重定向到另外四个不同的服务器和另外两个不在负载平衡服务器场上的服务器。配置看起来像是系统管理员完美完成的。
我面临的问题是,当我想要一个 HTTP Web 响应并获取响应标头时,我遇到了一个问题。我面临的问题是我从负载平衡服务器使用的负载平衡“链接”没有给我预期的响应。我以下面的代码为例。
try
{
var myHttpWebRequest = WebRequest.Create(url);
myHttpWebRequest.Credentials = credentials;
var myHttpWebResponse = myHttpWebRequest.GetResponse();
myHttpWebResponse.Close();
}
catch (WebException e)
{
Console.WriteLine("WebException: " + url);
Console.WriteLine("Web Exception Status: " + e.Status);
Console.WriteLine("\n");
if (e.Status == WebExceptionStatus.ProtocolError)
{
Console.WriteLine(((HttpWebResponse)e.Response).Headers);
}
}
现在,我在负载平衡服务器上执行代码时采用的 WebExceptionStatus 是“SendFailure”,它不会给我任何“response.headers”结果。
如果我安装并使用“curl”
curl [load balance server url] -k -I
在命令行上,当我使用负载平衡服务器 URL 时,我将使用标头。
总之,我的目标是出于某些目的,我想采用并使用 theWebExceptionStatus、“X-FEServer”、“www-Authenticate”和“Date”,但无法使用上述 c# 方法进行检索。
请确保您在任何评论或回答之前了解负载平衡服务器的方法。任何建议都会有所帮助